From: Dominik Stadler Date: Sat, 8 Mar 2014 16:46:59 +0000 (+0000) Subject: Adjust for JDK 8 where an empty locale is added to the array returned by DateFormat... X-Git-Tag: REL_3_11_BETA1~227 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b9cd5ca769009bb3dad5f18dd85ca0b71d7c4d7e;p=poi.git Adjust for JDK 8 where an empty locale is added to the array returned by DateFormat.getAvailableLocales() git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1575563 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/util/DateFormatConverter.java b/src/java/org/apache/poi/ss/util/DateFormatConverter.java index 316d1ed7b6..bca998e806 100644 --- a/src/java/org/apache/poi/ss/util/DateFormatConverter.java +++ b/src/java/org/apache/poi/ss/util/DateFormatConverter.java @@ -93,6 +93,7 @@ public class DateFormatConverter { return result.toArray(new String[0]); } + @Override public String toString() { StringBuilder result = new StringBuilder(); @@ -323,6 +324,9 @@ public class DateFormatConverter { result.put( "in", "[$-0421]" ); result.put( "iw", "[$-40D]" ); + // JDK 8 adds an empty locale-string, see also https://issues.apache.org/jira/browse/LANG-941 + result.put( "", "[$-0409]" ); + return result; } diff --git a/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java b/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java index e4b7c38927..95042e50f3 100644 --- a/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java +++ b/src/testcases/org/apache/poi/ss/util/TestDateFormatConverter.java @@ -137,5 +137,11 @@ public final class TestDateFormatConverter extends TestCase { outputLocaleDataFormats(date, false, true, DateFormat.LONG, "Long" ); outputLocaleDataFormats(date, false, true, DateFormat.FULL, "Full" ); } + + public void testJDK8EmptyLocale() { + // JDK 8 seems to add an empty locale-string to the list returned via DateFormat.getAvailableLocales() + // therefore we now cater for this special locale as well + DateFormatConverter.getPrefixForLocale(new Locale("")); + } }