From 66b39c70ade38bdff3a5260a3ef2324f4001cc61 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 23 Jun 2017 23:42:25 +0000 Subject: [PATCH] Bug 60422 add testtestcase with current LocaleUtil workaround git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1799721 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/usermodel/TestDataFormatter.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java index b4f3b7dde..03b8398e3 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java +++ b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java @@ -851,4 +851,25 @@ public class TestDataFormatter { assertEquals("08:51", dfUS.formatRawCellContents(42605.368761574071, -1, "hh:mm")); assertEquals("51:01", dfUS.formatRawCellContents(42605.368761574071, -1, "mm:ss")); } + + /** + * bug 60422 : DataFormatter has issues with a specific NumberFormat in Germany default locale + * Currently, this test only passes if you set LocaleUtil.setUserLocale(Locale.ROOT) or Locale.US. + */ + @Test + public void testBug60422() { + Locale defaultLocale = Locale.getDefault(); + Locale.setDefault(Locale.GERMANY); + LocaleUtil.setUserLocale(Locale.ROOT); + try { + char euro = '\u20AC'; + DataFormatter df = new DataFormatter(); + String formatString = String.format( + "_-* #,##0.00\\ \"%s\"_-;\\-* #,##0.00\\ \"%s\"_-;_-* \"-\"??\\ \"%s\"_-;_-@_-", + euro, euro, euro); + assertEquals("4.33 " + euro, df.formatRawCellContents(4.33, 178, formatString)); + } finally { + Locale.setDefault(defaultLocale); + } + } }