aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2017-01-26 19:58:18 +0000
committerDominik Stadler <centic@apache.org>2017-01-26 19:58:18 +0000
commit749f8d09ead0393833a8141597f586d27a87a7a1 (patch)
tree13ea1c651afc1bb98f51b17c65b6ecbb079dc908 /src/testcases/org/apache
parent80e397389f858945701011ebae3c782188e1fb61 (diff)
downloadpoi-749f8d09ead0393833a8141597f586d27a87a7a1.tar.gz
poi-749f8d09ead0393833a8141597f586d27a87a7a1.zip
Bug 60031: Enhance test some more
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1780450 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
index 8e6e38932d..4b196316e7 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
@@ -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"));
}
}