mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-13489 Merging #13442 (r40673, r40677) DecimalFormat.getGroupingSize() returns -1 instead of 0 in ICU60 if grouping is disabled to maint-60 for 60.2.
X-SVN-Rev: 40691
This commit is contained in:
parent
abcae9f4b1
commit
415164bf13
3 changed files with 13 additions and 5 deletions
|
@ -979,7 +979,7 @@ public class Parse {
|
|||
if (mode == null) mode = ParseMode.LENIENT;
|
||||
boolean integerOnly = properties.getParseIntegerOnly();
|
||||
boolean ignoreExponent = properties.getParseNoExponent();
|
||||
boolean ignoreGrouping = properties.getGroupingSize() < 0;
|
||||
boolean ignoreGrouping = properties.getGroupingSize() <= 0;
|
||||
|
||||
// Set up the initial state
|
||||
ParserState state = threadLocalParseState.get().clear();
|
||||
|
@ -1317,7 +1317,7 @@ public class Parse {
|
|||
numGroupingRegions--;
|
||||
}
|
||||
}
|
||||
if (grouping1 < 0) {
|
||||
if (grouping1 <= 0) {
|
||||
// OK (no grouping data available)
|
||||
} else if (numGroupingRegions <= 1) {
|
||||
// OK (no grouping digits)
|
||||
|
|
|
@ -1793,7 +1793,7 @@ public class DecimalFormat extends NumberFormat {
|
|||
*/
|
||||
@Override
|
||||
public synchronized boolean isGroupingUsed() {
|
||||
return properties.getGroupingSize() != -1 || properties.getSecondaryGroupingSize() != -1;
|
||||
return properties.getGroupingSize() > 0 || properties.getSecondaryGroupingSize() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1819,8 +1819,8 @@ public class DecimalFormat extends NumberFormat {
|
|||
// Set to a reasonable default value
|
||||
properties.setGroupingSize(3);
|
||||
} else {
|
||||
properties.setGroupingSize(-1);
|
||||
properties.setSecondaryGroupingSize(-1);
|
||||
properties.setGroupingSize(0);
|
||||
properties.setSecondaryGroupingSize(0);
|
||||
}
|
||||
refreshFormatter();
|
||||
}
|
||||
|
|
|
@ -5320,6 +5320,14 @@ public class NumberFormatTest extends TestFmwk {
|
|||
130, resultScientific.longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Test13442() {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setGroupingUsed(false);
|
||||
assertEquals("Grouping size should now be zero", 0, df.getGroupingSize());
|
||||
assertEquals("Grouping should be off", false, df.isGroupingUsed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPercentZero() {
|
||||
DecimalFormat df = (DecimalFormat) NumberFormat.getPercentInstance();
|
||||
|
|
Loading…
Add table
Reference in a new issue