ICU-20264 FixedDecimal.toString locale independent

This commit is contained in:
Frank Tang 2019-03-11 20:01:30 -07:00 committed by Frank Yung-Fong Tang
parent 994edfe858
commit ee71b22847
2 changed files with 12 additions and 1 deletions

View 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);
}
/**

View 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());
}
}