ICU-13006 DateFormat.setNumberFormat should clone the NumberFormat and also call setGroupingUsed(false)

X-SVN-Rev: 40198
This commit is contained in:
Peter Edberg 2017-06-23 06:26:30 +00:00
parent 4a499c9a77
commit 2cea868e02
4 changed files with 9 additions and 3 deletions

View File

@ -586,6 +586,7 @@ DateFormat::adoptNumberFormat(NumberFormat* newNumberFormat)
delete fNumberFormat;
fNumberFormat = newNumberFormat;
newNumberFormat->setParseIntegerOnly(TRUE);
newNumberFormat->setGroupingUsed(FALSE);
}
//----------------------------------------------------------------------

View 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);

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

View 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);