On 7/10/23 12:49 PM, Bruno Borges wrote:
Given that "en_US" is well known and commonly a user input data, what is
then the ideal way to create a Locale object for such string input?
Then use Locale.forLanguageTag(). It will accept BCP 47 Langauge tag.
You will need to replace `_` with `-`.
And isn't this the case of a breaking change more than just updating the
time database used by default in JDK?
You could specify the system property `java.locale.providers` to COMPAT
to use the JDK8 locales (although this has been deprecated in JDK21).
However, expecting US resources with Locale("en_US") is incorrect in the
first place.
Perhaps in other words, shouldn't Locale(String) constructor attempt to
parse the input for the Locale(String, String) constructor so the
behavior would have been maintained in accordance to Java 8?
Don't think so. The spec of Locale(String) is clear that it won't do any
syntactic checks on the input. Otherwise if someone had been creating
"xxx_yyy" as a language, it will break.
Naoto
Sent from mobile device.
------------------------------------------------------------------------
*From:* Naoto Sato <naoto.s...@oracle.com>
*Sent:* Monday, July 10, 2023 12:36:10 PM
*To:* Bruno Borges <bruno.bor...@microsoft.com>;
core-libs-dev@openjdk.org <core-libs-dev@openjdk.org>
*Subject:* [EXTERNAL] Re: 4-letter patterns in Date Format Style no
longer give full text style
Hi,
In your test case,
```
new Locale("en_US");
```
This will fall back to ROOT locale texts with CLDR (default since JDK9)
where it differs from US English. Probably you may want to `new
Locale("en", "US)` or preferably use `Locale.US` constant.
Naoto
On 7/10/23 12:08 PM, Bruno Borges wrote:
Hi all,
Was there any change to Date Time Formatter API that made the "EEEE" and
the "MMMM" (and other 4-letter patterns) change from Java 8 to 11+ ?
In Java 8, "EEEE" with locale en_US correctly gives the FULL day of
week, e.g., "Monday".
In Java 11 and 17 (two I've tested), the same input will give "Mon".
I've also tested for "MMMM" expecting "July" (as in 8), but in 11/17 I
get only "Jul".
Here's a test case:
brunoborges/date-formatting-bug@f8f84a1 (github.com)
<https://github.com/brunoborges/date-formatting-bug/actions/runs/5511890139/jobs/10048031299 <https://urldefense.com/v3/__https://github.com/brunoborges/date-formatting-bug/actions/runs/5511890139/jobs/10048031299__;!!ACWV5N9M2RV99hQ!JFb8UvDcd0yJhPFTBgCl61gnX6IBN2X7VtRBoKwvcLBkHwCJxL6QM52A6g7Lq960cGc9hgiqdusTFB7YMNgvlIdG$>>
Thanks,
Bruno