aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2010-05-28 16:47:01 +0000
committerNick Burch <nick@apache.org>2010-05-28 16:47:01 +0000
commite139dd8ecf9d912f6fe059b1357250cd53abe943 (patch)
tree59823d15113e9b76c338821427941cada5165d98
parent8bb16bee4bd474af96970a5f07c469ef50ab8c2e (diff)
downloadpoi-e139dd8ecf9d912f6fe059b1357250cd53abe943.tar.gz
poi-e139dd8ecf9d912f6fe059b1357250cd53abe943.zip
Support a couple more crazy formats, as identified in bug #48872, plus test them
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@949226 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/poi/ss/usermodel/DateUtil.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/ss/usermodel/DateUtil.java b/src/java/org/apache/poi/ss/usermodel/DateUtil.java
index 238eefb920..fb2bfd94d2 100644
--- a/src/java/org/apache/poi/ss/usermodel/DateUtil.java
+++ b/src/java/org/apache/poi/ss/usermodel/DateUtil.java
@@ -52,7 +52,7 @@ public class DateUtil {
*/
private static final Pattern date_ptrn1 = Pattern.compile("^\\[\\$\\-.*?\\]");
private static final Pattern date_ptrn2 = Pattern.compile("^\\[[a-zA-Z]+\\]");
- private static final Pattern date_ptrn3 = Pattern.compile("^[yYmMdDhHsS\\-/,. :\\\\]+[ampAMP/]*$");
+ private static final Pattern date_ptrn3 = Pattern.compile("^[yYmMdDhHsS\\-/,. :\"\\\\]+0?[ampAMP/]*$");
/**
* Given a Date, converts it into a double representing its internal Excel representation,
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
index 1becfcb36d..cab1467d8f 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java
@@ -242,8 +242,8 @@ public final class TestHSSFDateUtil extends TestCase {
"dd.mm.yyyy", "dd\\.mm\\.yyyy",
"dd\\ mm\\.yyyy AM", "dd\\ mm\\.yyyy pm",
"dd\\ mm\\.yyyy\\-dd", "[h]:mm:ss",
-
- //YK: TODO "mm:ss.0" is a built-in date format which is not recognized by DateUtil.isInternalDateFormat
+ "mm/dd/yy", "\"mm\"/\"dd\"/\"yy\"",
+ "m\\/d\\/yyyy",
// These crazy ones are valid
"yyyy-mm-dd;@", "yyyy/mm/dd;@",
@@ -269,7 +269,9 @@ public final class TestHSSFDateUtil extends TestCase {
"mm/dd HH:MM", "yy/mmm/dd SS",
"mm/dd HH:MM AM", "mm/dd HH:MM am",
"mm/dd HH:MM PM", "mm/dd HH:MM pm",
- "m/d/yy h:mm AM/PM"
+ "m/d/yy h:mm AM/PM",
+ "hh:mm:ss", "hh:mm:ss.0", "mm:ss.0",
+
};
for(int i=0; i<formats.length; i++) {
assertTrue(