]> granicus.if.org Git - icu/commitdiff
ICU-20264 FixedDecimal.toString locale independent
authorFrank Tang <ftang@chromium.org>
Tue, 12 Mar 2019 03:01:30 +0000 (20:01 -0700)
committerFrank Yung-Fong Tang <41213225+FrankYFTang@users.noreply.github.com>
Tue, 12 Mar 2019 04:42:00 +0000 (21:42 -0700)
icu4j/main/classes/core/src/com/ibm/icu/text/PluralRules.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/PluralRulesTest.java

index 708edee7c29ed4909f199c40bad72e6b3fee40f4..272624a8e6956e5c8549aab9acc0d46e9ae463d9 100644 (file)
@@ -882,7 +882,7 @@ public class PluralRules implements Serializable {
         @Deprecated
         @Override
         public String toString() {
-            return String.format("%." + visibleDecimalDigitCount + "f", source);
+            return String.format(Locale.ROOT, "%." + visibleDecimalDigitCount + "f", source);
         }
 
         /**
index 5976761defe2e866fa74e6d658208fc0430447fa..906ad328956613397d4f22f435eacfb09a52ebb2 100644 (file)
@@ -1186,4 +1186,15 @@ public class PluralRulesTest extends TestFmwk {
         PluralRules rulesJ1 = PluralRules.forLocale(Locale.FRANCE, PluralType.ORDINAL);
         assertEquals("forLocale() with type", rulesU1, rulesJ1);
     }
+
+    @Test
+    public void testBug20264() {
+        String expected = "1.23400";
+        FixedDecimal fd = new FixedDecimal(1.234, 5, 2);
+        assertEquals("FixedDecimal toString", expected, fd.toString());
+        Locale.setDefault(Locale.FRENCH);
+        assertEquals("FixedDecimal toString", expected, fd.toString());
+        Locale.setDefault(Locale.GERMAN);
+        assertEquals("FixedDecimal toString", expected, fd.toString());
+    }
 }