poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1779564 - in /poi/trunk/src: java/org/apache/poi/ss/usermodel/DataFormatter.java testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
Date Fri, 20 Jan 2017 05:35:57 GMT
Author: onealj
Date: Fri Jan 20 05:35:57 2017
New Revision: 1779564

URL: http://svn.apache.org/viewvc?rev=1779564&view=rev
Log:
bug 60031: DataFormatter parses months incorrectly when put at the end of date segment. Thanks
to Andrzej Witecki

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1779564&r1=1779563&r2=1779564&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Fri Jan 20 05:35:57
2017
@@ -582,6 +582,9 @@ public class DataFormatter implements Ob
                 }
             }
             else {
+                if (Character.isWhitespace(c)){
+                    ms.clear();
+                }
                 sb.append(c);
             }
         }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java?rev=1779564&r1=1779563&r2=1779564&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java Fri Jan 20
05:35:57 2017
@@ -815,5 +815,17 @@ public class TestDataFormatter {
         assertEquals("5.6789", formatter.formatCellValue(cell, evaluator));
 
         wb.close();
+    }
+    
+    /**
+     * bug 60031: DataFormatter parses months incorrectly when put at the end of date segment
+     */
+    @Test
+    public void testBug60031() {
+        // 23-08-2016 08:51:01 which is 42605.368761574071 as double will be parsed
+        // with format "yyyy-dd-MM HH:mm:ss" into "2016-23-51 08:51:01".
+        DataFormatter dfUS = new DataFormatter(Locale.US);
+        assertEquals("2016-23-08 08:51:01", dfUS.formatRawCellContents(42605.368761574071,
-1, "yyyy-dd-MM HH:mm:ss"));
+        assertEquals("2017-12-01 January 09:54:33", dfUS.formatRawCellContents(42747.412892397523,
-1, "yyyy-dd-MM MMMM HH:mm:ss"));
     }
 }



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


Mime
View raw message