diff options
author | Javen O'Neal <onealj@apache.org> | 2017-02-08 08:29:18 +0000 |
---|---|---|
committer | Javen O'Neal <onealj@apache.org> | 2017-02-08 08:29:18 +0000 |
commit | d5724474e6169b34919c36b0f319ebd9254e5c39 (patch) | |
tree | 6ff9ab72eea07aab0d3bba83e21eba309b2f6741 /src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java | |
parent | 9ebbb3d7270a600718d4aae748acc6fa2c925b0e (diff) | |
download | poi-d5724474e6169b34919c36b0f319ebd9254e5c39.tar.gz poi-d5724474e6169b34919c36b0f319ebd9254e5c39.zip |
bug 59227: parse dates formatted in Japanese or Chinese. Change javac source encoding from ASCII to UTF-8 (same as build.gradle). Patch from jzhao. This closes #48 on Github.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1782119 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java')
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java b/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java index 3f0ef4b7c1..3a79c6181c 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java +++ b/src/testcases/org/apache/poi/ss/usermodel/TestDateUtil.java @@ -18,6 +18,7 @@ package org.apache.poi.ss.usermodel; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.Calendar; import java.util.Date; @@ -92,4 +93,34 @@ public class TestDateUtil { assertEquals(expCal, actCal[2]); assertEquals(expCal, actCal[3]); } + + @Test + public void isADateFormat() { + // Cell content 2016-12-8 as an example + // Cell show "12/8/2016" + assertTrue(DateUtil.isADateFormat(14, "m/d/yy")); + // Cell show "Thursday, December 8, 2016" + assertTrue(DateUtil.isADateFormat(182, "[$-F800]dddd\\,\\ mmmm\\ dd\\,\\ yyyy")); + // Cell show "12/8" + assertTrue(DateUtil.isADateFormat(183, "m/d;@")); + // Cell show "12/08/16" + assertTrue(DateUtil.isADateFormat(184, "mm/dd/yy;@")); + // Cell show "8-Dec-16" + assertTrue(DateUtil.isADateFormat(185, "[$-409]d\\-mmm\\-yy;@")); + // Cell show "D-16" + assertTrue(DateUtil.isADateFormat(186, "[$-409]mmmmm\\-yy;@")); + + // Cell show "2016年12月8日" + assertTrue(DateUtil.isADateFormat(165, "yyyy\"年\"m\"月\"d\"日\";@")); + // Cell show "2016年12月" + assertTrue(DateUtil.isADateFormat(164, "yyyy\"年\"m\"月\";@")); + // Cell show "12月8日" + assertTrue(DateUtil.isADateFormat(168, "m\"月\"d\"日\";@")); + // Cell show "十二月八日" + assertTrue(DateUtil.isADateFormat(181, "[DBNum1][$-404]m\"月\"d\"日\";@")); + // Cell show "贰零壹陆年壹拾贰月捌日" + assertTrue(DateUtil.isADateFormat(177, "[DBNum2][$-804]yyyy\"年\"m\"月\"d\"日\";@")); + // Cell show "2016年12月8日" + assertTrue(DateUtil.isADateFormat(178, "[DBNum3][$-804]yyyy\"年\"m\"月\"d\"日\";@")); + } } |