ICU-13442 Fixing checks for whether or not grouping is enabled. A grouping size of zero means that grouping is disabled.

X-SVN-Rev: 40677
This commit is contained in:
Shane Carr 2017-11-29 23:44:28 +00:00
parent 254e5f9580
commit 3a1ee31d76
3 changed files with 4 additions and 3 deletions

View file

@ -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)

View file

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

View file

@ -5325,6 +5325,7 @@ public class NumberFormatTest extends TestFmwk {
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