RFR: 8176706: Additional Date-Time Formats [v2]

Naoto Sato naoto at openjdk.java.net
Tue Feb 8 18:47:06 UTC 2022


On Tue, 8 Feb 2022 00:39:04 GMT, Joe Wang <joehw at openjdk.org> wrote:

>> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Modified per suggestions on the PR
>
> src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java line 254:
> 
>> 252:     public static String getLocalizedDateTimePattern(String requestedTemplate,
>> 253:                                                      Chronology chrono, Locale locale) {
>> 254:         Objects.requireNonNull(locale, "requestedTemplate");
> 
> Typo, "locale" should have been requestedTemplate.

Good catch!

> src/java.base/share/classes/sun/util/locale/provider/JavaTimeDateTimePatternImpl.java line 77:
> 
>> 75:         LocaleProviderAdapter lpa = LocaleProviderAdapter.getResourceBundleBased();
>> 76:         // CLDR's 'u'/'U' are not supported in the JDK. Replace them with 'y' instead
>> 77:         final var modifiedSkeleton = requestedTemplate.replaceAll("[uU]", "y");
> 
> Seems to me requestedTemplate needs to be validated when it gets passed to getLocalizedDateTimePattern,  similar as to appendLocalized

This was a left over which should be removed. In fact, CLDR specific pattern symbols should not be accepted as the requested template. Removed the substitutions. As to the validation, it will be performed in the following `LocaleResources.getLocalizedPattern()` method.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7340


More information about the core-libs-dev mailing list