]> granicus.if.org Git - icu/commitdiff
ICU-13442 Fixing checks for whether or not grouping is enabled. A grouping size...
authorShane Carr <shane@unicode.org>
Wed, 29 Nov 2017 23:44:28 +0000 (23:44 +0000)
committerShane Carr <shane@unicode.org>
Wed, 29 Nov 2017 23:44:28 +0000 (23:44 +0000)
X-SVN-Rev: 40677

icu4j/main/classes/core/src/com/ibm/icu/impl/number/Parse.java
icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java

index 50d0f3c70ee911df6617d5beca9325e44ab3ccaf..efb0e5002d88e43ab79bc00a2c96bfdb5a068514 100644 (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)
index 9829801332ffe136b4675711f09ffbcc41edf359..58a0189783bffebb096a1e75f564d675c6595204 100644 (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;
   }
 
   /**
index 3bb777eb64162bee71522e37a9f95606ffc44644..74290f3b0b0ba5608d6666daabfeb96b4cf8dd37 100644 (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