<i18n dev> RFR: 8283698: Refactor Locale constructors used in src/test

Joe Wang joehw at openjdk.java.net
Thu Apr 7 04:59:40 UTC 2022


On Thu, 7 Apr 2022 01:16:32 GMT, Naoto Sato <naoto at openjdk.org> wrote:

>> test/jdk/java/text/Format/NumberFormat/CurrencyFormat.java line 63:
>> 
>>> 61:             Locale.of("it", "IT", "EURO"),
>>> 62:             Locale.forLanguageTag("de-AT"),
>>> 63:             Locale.forLanguageTag("fr-CH"),
>> 
>> Use the new factory? Ok not to change as these are tests and there are too many of them. It's not deprecated anyways.
>
> `Locale.forLanguageTag()` is a preferred way to create a `Locale`, as it validates the input language tag, while `Locale.of()` doesn't as well as Locale constructors.

Ok, I didn't realize the existing method is preferred over the new method in creating a Locale. The javadoc does state that it does not make any syntactic checks. That's good to know.

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

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


More information about the i18n-dev mailing list