]> source.dussan.org Git - poi.git/commitdiff
Add AM/PM DataFormatter tests for bug #52389 (already working properly)
authorNick Burch <nick@apache.org>
Wed, 28 Dec 2011 05:16:36 +0000 (05:16 +0000)
committerNick Burch <nick@apache.org>
Wed, 28 Dec 2011 05:16:36 +0000 (05:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1225095 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java

index 874725aad2c96efd81cdace2e19c5d9f8df6d4dc..c8c4cdbe6f900a63e44648f6e50aa4a2f8892795 100644 (file)
@@ -245,6 +245,22 @@ public class TestDataFormatter extends TestCase {
        ));
     }
     
+    /**
+     * Tests that we do AM/PM handling properly
+     */
+    public void testAMPM() {
+       DataFormatter dfUS = new DataFormatter(Locale.US);
+       
+       assertEquals("06:00", dfUS.formatRawCellContents(0.25, -1, "hh:mm"));
+       assertEquals("18:00", dfUS.formatRawCellContents(0.75, -1, "hh:mm"));
+       
+       assertEquals("06:00 AM", dfUS.formatRawCellContents(0.25, -1, "hh:mm AM/PM"));
+       assertEquals("06:00 PM", dfUS.formatRawCellContents(0.75, -1, "hh:mm AM/PM"));
+       
+       assertEquals("1904-01-01 06:00:00 AM", dfUS.formatRawCellContents(0.25, -1, "yyyy-mm-dd hh:mm:ss AM/PM", true));
+       assertEquals("1904-01-01 06:00:00 PM", dfUS.formatRawCellContents(0.75, -1, "yyyy-mm-dd hh:mm:ss AM/PM", true));
+    }
+    
     /**
      * Test that we can handle elapsed time,
      *  eg formatting 1 day 4 hours as 28 hours