From 748647c9c04a95f37f2e37e222cfc9ca1bbf7842 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 20 May 2008 16:37:15 +0000 Subject: [PATCH] Fix bug #44977 - Support for AM/PM in excel date formats git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@658322 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 1 + src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java | 3 ++- .../org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index acf5cfeab..ebb063f27 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 44977 - Support for AM/PM in excel date formats Support for specifying a policy to HSSF on missing / blank cells when fetching 44937 - Partial support for extracting Escher images from HWPF files 44824 - Avoid an infinite loop when reading some HWPF pictures diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 41b47b996..2167a4257 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 44977 - Support for AM/PM in excel date formats Support for specifying a policy to HSSF on missing / blank cells when fetching 44937 - Partial support for extracting Escher images from HWPF files 44824 - Avoid an infinite loop when reading some HWPF pictures diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java index 0e3d1ee54..910d2737c 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java @@ -226,7 +226,8 @@ public class HSSFDateUtil // Otherwise, check it's only made up, in any case, of: // y m d h s - / , . : - if(fs.matches("^[yYmMdDhHsS\\-/,. :]+$")) { + // optionally followed by AM/PM + if(fs.matches("^[yYmMdDhHsS\\-/,. :]+[ampAMP]*$")) { return true; } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java index 861f5ed7f..6540f8f09 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java @@ -266,6 +266,8 @@ public class TestHSSFDateUtil extends TestCase { formats = new String[] { "yyyy-mm-dd hh:mm:ss", "yyyy/mm/dd HH:MM:SS", "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" }; for(int i=0; i