]> granicus.if.org Git - icu/commitdiff
ICU-13006 DateFormat.setNumberFormat should clone the NumberFormat and also call...
authorPeter Edberg <pedberg@unicode.org>
Fri, 23 Jun 2017 06:26:30 +0000 (06:26 +0000)
committerPeter Edberg <pedberg@unicode.org>
Fri, 23 Jun 2017 06:26:30 +0000 (06:26 +0000)
X-SVN-Rev: 40198

icu4c/source/i18n/datefmt.cpp
icu4c/source/test/intltest/numrgts.cpp
icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java

index 3e879be44472f203ca288e0e392506dc6cdfd57a..f6a0d892388755fe81acb6670f3b13078857fdbf 100644 (file)
@@ -586,6 +586,7 @@ DateFormat::adoptNumberFormat(NumberFormat* newNumberFormat)
     delete fNumberFormat;
     fNumberFormat = newNumberFormat;
     newNumberFormat->setParseIntegerOnly(TRUE);
+    newNumberFormat->setGroupingUsed(FALSE);
 }
 //----------------------------------------------------------------------
 
index 5e449279d22a3d419feec8dda50bc9f844f265cf..e4852bd4cdcb6203a8541e79916c1b5ae4e0477a 100644 (file)
@@ -2684,6 +2684,9 @@ void NumberFormatRegressionTest::TestJ691(void) {
 
     // *** Here's the key: We don't want to have to do THIS:
     // nf->setParseIntegerOnly(TRUE);
+    // or this (with changes to fr_CH per cldrbug:9370):
+    // nf->setGroupingUsed(FALSE);
+    // so they are done in DateFormat::adoptNumberFormat
 
     // create the DateFormat
     DateFormat *df = DateFormat::createDateInstance(DateFormat::kShort, loc);
index 7d120c9eee6f9e0e7bbd1e9502f023c3c2f45d40..8e87423c6d38190e3b202fce57e4c3dbd11787d9 100644 (file)
@@ -1571,11 +1571,12 @@ public abstract class DateFormat extends UFormat {
      */
     public void setNumberFormat(NumberFormat newNumberFormat)
     {
-        this.numberFormat = newNumberFormat;
+        this.numberFormat = (NumberFormat)newNumberFormat.clone();
         /*In order to parse String like "11.10.2001" to DateTime correctly
           in Locale("fr","CH") [Richard/GCL]
         */
         this.numberFormat.setParseIntegerOnly(true);
+        this.numberFormat.setGroupingUsed(false);
     }
 
     /**
index 4a983398051dc6607f0fd10163e1bd5ad7950f7e..d7d1f600efc5ecdf536d8dd9a90c3b93bf86db02 100644 (file)
@@ -73,8 +73,9 @@ public class NumberFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
 
         // *** Here's the key: We don't want to have to do THIS:
         //nf.setParseIntegerOnly(true);
-        // However with changes to fr_CH per cldrbug:9370 we have to do the following:
-        nf.setGroupingUsed(false);
+        // or this (with changes to fr_CH per cldrbug:9370):
+        //nf.setGroupingUsed(false);
+        // so they are done in DateFormat.setNumberFormat
     
         // create the DateFormat
         DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, loc);