From 6cc974bd7280a7f685499d13b48c78b22803be98 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 18 Jul 2008 17:16:50 +0000 Subject: [PATCH] Patch from bug #45398 - Support detecting date formats containing "am/pm" as date times git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@677974 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 | 2 +- .../org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 3e37911e84..caa238df59 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 45398 - Support detecting date formats containing "am/pm" as date times 45410 - Removed dependency from contrib on commons beanutils,collections and lang New helper, HSSFOptimiser, which handles removing duplicated font and style records, to avoid going over the limits in Excel 45322 - Fixed NPE in HSSFSheet.autoSizeColumn() when cell number format was not found diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 511b570a2d..798d358294 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 45398 - Support detecting date formats containing "am/pm" as date times 45410 - Removed dependency from contrib on commons beanutils,collections and lang New helper, HSSFOptimiser, which handles removing duplicated font and style records, to avoid going over the limits in Excel 45322 - Fixed NPE in HSSFSheet.autoSizeColumn() when cell number format was not found diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java index be590c3a2d..ab353ca02c 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFDateUtil.java @@ -231,7 +231,7 @@ public class HSSFDateUtil // Otherwise, check it's only made up, in any case, of: // y m d h s - / , . : // optionally followed by AM/PM - if(fs.matches("^[yYmMdDhHsS\\-/,. :]+[ampAMP]*$")) { + 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 2ac4eb825f..894c77d685 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDateUtil.java @@ -273,7 +273,8 @@ public class TestHSSFDateUtil extends TestCase { "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" + "mm/dd HH:MM PM", "mm/dd HH:MM pm", + "m/d/yy h:mm AM/PM" }; for(int i=0; i