Author: centic
Date: Thu Jan 26 19:58:18 2017
New Revision: 1780450

URL: http://svn.apache.org/viewvc?rev=1780450&view=rev
Log:
Bug 60031: Enhance test some more

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

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=1780450&r1=1780449&r2=1780450&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 
Thu Jan 26 19:58:18 2017
@@ -815,17 +815,30 @@ 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);
+     */
+    @Test
+    public void testBug60031() {
+        // 23-08-2016 08:51:01 which is 42605.368761574071 as double was 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"));
+        assertEquals("2016-23 08:51:01 08", 
dfUS.formatRawCellContents(42605.368761574071, -1, "yyyy-dd HH:mm:ss MM"));
+        assertEquals("2017-12-01 January 09:54:33", 
dfUS.formatRawCellContents(42747.412892397523, -1, "yyyy-dd-MM MMMM HH:mm:ss"));
+        assertEquals("08", dfUS.formatRawCellContents(42605.368761574071, -1, 
"MM"));
+        assertEquals("01", dfUS.formatRawCellContents(42605.368761574071, -1, 
"ss"));
+
+        // From Excel help:
+        /*
+            The "m" or "mm" code must appear immediately after the "h" or"hh"
+            code or immediately before the "ss" code; otherwise, Microsoft
+            Excel displays the month instead of minutes."
+          */
+        assertEquals("08", dfUS.formatRawCellContents(42605.368761574071, -1, 
"mm"));
+        assertEquals("08:51", dfUS.formatRawCellContents(42605.368761574071, 
-1, "hh:mm"));
+        assertEquals("51:01", dfUS.formatRawCellContents(42605.368761574071, 
-1, "mm:ss"));
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to