You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/01/18 22:35:38 UTC

svn commit: r1851651 - /xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java

Author: kiwiwings
Date: Fri Jan 18 22:35:38 2019
New Revision: 1851651

URL: http://svn.apache.org/viewvc?rev=1851651&view=rev
Log:
XMLBEANS-529: Format xmlobjects to the correct string representation on XPath access

Modified:
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java?rev=1851651&r1=1851650&r2=1851651&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java Fri Jan 18 22:35:38 2019
@@ -16,6 +16,8 @@
 package org.apache.xmlbeans.impl.store;
 
 import java.io.*;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 import java.lang.reflect.Method;
@@ -609,6 +611,8 @@ public abstract class Path
                 extends XPath.ExecutionContext
                 implements PathEngine
         {
+            // full datetime format: yyyy-MM-dd'T'HH:mm:ss'Z'
+            private final DateFormat xmlDateFormat = new SimpleDateFormat("yyyy-MM-dd");
 
             DelegatePathEngine(PathDelegate.SelectPathInterface xpathImpl,
                                Cur c)
@@ -640,9 +644,15 @@ public abstract class Path
                     Object node = resultsList.get(i);
                     Cur pos = null;
                     if (!(node instanceof Node)) {
+                        Object obj = resultsList.get(i);
                         String value;
-
-                        value = resultsList.get(i).toString();
+                        if (obj instanceof Date) {
+                            value = xmlDateFormat.format((Date) obj);
+                        } else if (obj instanceof BigDecimal) {
+                            value = ((BigDecimal)obj).toPlainString();
+                        } else {
+                            value = obj.toString();
+                        }
 
                         //we cannot leave the cursor's locale, as
                         //everything is done in the selections of this cursor



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org