From ed2e2a28bc9e163edd8bc8a8bb79b7d7478eed4b Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Fri, 16 Aug 2013 09:38:47 +0000 Subject: [PATCH] Bug 54786: Fix missing quoting in date formatting, add a number of unit tests which verify the new formatting options. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1514632 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/usermodel/DataFormatter.java | 24 +++++++++++++++- .../poi/ss/usermodel/TestDataFormatter.java | 28 ++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index 46740cc38..4e3718e95 100644 --- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java +++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java @@ -423,6 +423,8 @@ public class DataFormatter { formatStr = formatStr.replaceAll("\\\\/","/"); // weird: m\\/d\\/yyyy formatStr = formatStr.replaceAll(";@", ""); formatStr = formatStr.replaceAll("\"/\"", "/"); // "/" is escaped for no reason in: mm"/"dd"/"yyyy + formatStr = formatStr.replace("\"\"", "'"); // replace Excel quoting with Java style quoting + boolean hasAmPm = false; Matcher amPmMatcher = amPmPattern.matcher(formatStr); @@ -456,7 +458,21 @@ public class DataFormatter { boolean isElapsed = false; for(int j=0; j