diff --git a/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java b/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java index 6699cea54..cc7d770fa 100644 --- a/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java +++ b/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java @@ -699,7 +699,7 @@ public static Double toNumeric(Object o) { val = NaN; } } else if (o instanceof Date) { - val = (double) DateUtils.daysSinceEpoch((Date) o); + val = (double) DateUtils.fractionalDaysSinceEpoch((Date) o); } else if (o instanceof IExprDataType) { val = ((IExprDataType) o).toNumeric(); } @@ -759,7 +759,7 @@ public static String toString(Object o) { } else if (o instanceof String) { val = (String) o; } else if (o instanceof Date) { - val = DateUtils.formatDate((Date) o, DateUtils.FORMAT_ISO8601); + val = DateUtils.formatDateTime((Date) o, DateUtils.FORMAT_ISO8601); } else if (o instanceof IExprDataType) { val = ((IExprDataType) o).toString(); } diff --git a/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java b/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java index c354511e2..a11170b42 100644 --- a/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java +++ b/src/test/java/org/javarosa/xpath/test/XPathEvalTest.java @@ -198,7 +198,8 @@ public void type_conversions() { testEval("string('')", ""); testEval("string(' ')", " "); testEval("string('a string')", "a string"); - testEval("string(date('1989-11-09'))", "1989-11-09"); + //For #637 + testEval("string(date('1989-11-09'))", "1989-11-09T00:00:00.000Z"); testEval("string(convertible())", null, ec, "hi"); testEval("string(inconvertible())", null, ec, new XPathTypeMismatchException()); testEval("int('100')", 100.0);