ICU-9612 Fix CompactDecimalFormat so that it handles periods correctly that appear in prefixes or suffixes.
X-SVN-Rev: 32450
This commit is contained in:
parent
ac84432516
commit
df0d824956
@ -269,9 +269,9 @@ class CompactDecimalDataCache {
|
||||
" in " + localeAndStyle(locale, style));
|
||||
}
|
||||
savePrefixOrSuffix(
|
||||
template.substring(0, firstIdx), pluralVariant, idx, result.prefixes);
|
||||
fixQuotes(template.substring(0, firstIdx)), pluralVariant, idx, result.prefixes);
|
||||
savePrefixOrSuffix(
|
||||
template.substring(lastIdx + 1), pluralVariant, idx, result.suffixes);
|
||||
fixQuotes(template.substring(lastIdx + 1)), pluralVariant, idx, result.suffixes);
|
||||
|
||||
// Calculate number of zeros before decimal point.
|
||||
int i = firstIdx + 1;
|
||||
@ -281,6 +281,9 @@ class CompactDecimalDataCache {
|
||||
return i - firstIdx;
|
||||
}
|
||||
|
||||
private static String fixQuotes(String prefixOrSuffix) {
|
||||
return prefixOrSuffix.replace("'.'", ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns locale and style. Used to form useful messages in thrown
|
||||
|
@ -107,6 +107,23 @@ public class CompactDecimalFormatTest extends TestFmwk {
|
||||
{12345678901234f, "T12"},
|
||||
{12345678901234567890f, "T12000000"},
|
||||
};
|
||||
|
||||
Object[][] CsTestDataShort = {
|
||||
{1000, "1\u00a0tis."},
|
||||
{1500, "1,5\u00a0tis."},
|
||||
{5000, "5\u00a0tis."},
|
||||
{23000, "23\u00a0tis."},
|
||||
{127123, "130\u00a0tis."},
|
||||
{1271234, "1,3\u00a0mil."},
|
||||
{12712345, "13\u00a0mil."},
|
||||
{127123456, "130\u00a0mil."},
|
||||
{1271234567f, "1,3\u00a0mld."},
|
||||
{12712345678f, "13\u00a0mld."},
|
||||
{127123456789f, "130\u00a0mld."},
|
||||
{1271234567890f, "1,3\u00a0bil."},
|
||||
{12712345678901f, "13\u00a0bil."},
|
||||
{127123456789012f, "130\u00a0bil."},
|
||||
};
|
||||
|
||||
public void TestCharacterIterator() {
|
||||
CompactDecimalFormat cdf =
|
||||
@ -129,6 +146,10 @@ public class CompactDecimalFormatTest extends TestFmwk {
|
||||
ULocale.forLanguageTag("ar"), CompactStyle.LONG);
|
||||
assertEquals("Arabic Long", "٥٫٣ ألف", cdf.format(5300));
|
||||
}
|
||||
|
||||
public void TestCsShort() {
|
||||
checkLocale(ULocale.forLanguageTag("cs"), CompactStyle.SHORT, CsTestDataShort);
|
||||
}
|
||||
|
||||
public void TestSerbianShort() {
|
||||
checkLocale(ULocale.forLanguageTag("sr"), CompactStyle.SHORT, SerbianTestDataShort);
|
||||
|
Loading…
Reference in New Issue
Block a user