8244245: localizedBy() should override localized values with default values

Reviewed-by: joehw, rriggs, scolebourne
This commit is contained in:
Naoto Sato 2020-05-07 09:27:48 -07:00
parent 29f015cf61
commit ed4bc1bf23
2 changed files with 93 additions and 29 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1499,18 +1499,20 @@ public final class DateTimeFormatter {
return this;
}
// Check for decimalStyle/chronology/timezone in locale object
Chronology c = locale.getUnicodeLocaleType("ca") != null ?
Chronology.ofLocale(locale) : chrono;
DecimalStyle ds = locale.getUnicodeLocaleType("nu") != null ?
DecimalStyle.of(locale) : decimalStyle;
// Override decimalStyle/chronology/timezone for the locale object
String tzType = locale.getUnicodeLocaleType("tz");
ZoneId z = tzType != null ?
ZoneId z = tzType != null ?
TimeZoneNameUtility.convertLDMLShortID(tzType)
.map(ZoneId::of)
.orElse(zone) :
zone;
return new DateTimeFormatter(printerParser, locale, ds, resolverStyle, resolverFields, c, z);
return new DateTimeFormatter(printerParser,
locale,
DecimalStyle.of(locale),
resolverStyle,
resolverFields,
Chronology.ofLocale(locale),
z);
}
//-----------------------------------------------------------------------