Language locales have different calendars than country locales in 9+
naoto.sato at oracle.com
naoto.sato at oracle.com
Fri Jul 31 21:24:33 UTC 2020
Hi Bernd,
As you pointed out, the change you see here is the result of this change
in JDK9:
https://bugs.openjdk.java.net/browse/JDK-8008577
where the default locale provider was switched to CLDR. Although we
don't describe those behavior changes in the spec (as it is regarded as
l10n changes which may differ across implementations), it was generally
noted in JDK9's release note:
---
As a result, users may see differences in locale sensitive services
behavior and/or translations. [1]
---
You can use the COMPAT provider through the java.locale.providers system
property if you need the pre-JDK9 behavior.
HTH,
Naoto
[1] https://www.oracle.com/java/technologies/javase/v9-issues-relnotes.html
On 7/31/20 1:17 PM, Bernd Eckenfels wrote:
> Hello,
>
> Just wanted to mention a thing I noticed when switching from 8 to 11. I knew before that the Locale data provider has changed, and I could notice that for example in the writing style for abbreviated words in dates. However something I did not expect is, that the definition of Calemdars change as well.
>
> Locale.GERMAN and Locale.GERMANY construct different calemdars under Java 11 with CLDR as opposed to Java 8 or Java 11 with compat. The most notably changes are when calculating calendar weeks (min days in first week) or the start of a week (Sunday vs. Monday).
>
> I haven't seen that explicitely mentioned and I also wonder if this should be mentioned in the Locale JavaDoc that language locales and country locales might differ severely in that aspect.
>
>
> GERMANY:
> Calendar.minDays 4 java.util.GregorianCalendar[time=1596218932830,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=…,firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2020,MONTH=6,WEEK_OF_YEAR=31,WEEK_OF_MONTH=5,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=8,SECOND=52,MILLISECOND=830,ZONE_OFFSET=3600000,DST_OFFSET=3600000]
> 11.0.1+13-LTS de_DE 2011-01-01 2010-52
>
> GERMAN
> Calendar.minDays 1 java.util.GregorianCalendar[time=1596218932879,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=...,firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2020,MONTH=6,WEEK_OF_YEAR=31,WEEK_OF_MONTH=5,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=8,SECOND=52,MILLISECOND=879,ZONE_OFFSET=3600000,DST_OFFSET=3600000]
> 11.0.1+13-LTS de 2011-01-01 2011-01
>
> Sample code:
>
> Date d = new Date(1293843600000L);
>
> Locale l = Locale.GERMANY;
>
> Calendar c = Calendar.getInstance(l);
> System.out.println("Calendar.minDays "+ c.getMinimalDaysInFirstWeek() + " " + c);
>
> SimpleDateFormat sdf = newSimpleDateFormat("yyyy-MM-DD YYYY-ww", l);
> System.out.printf("%s %-5s %s%n", System.getProperty("java.vm.version"), l, sdf.format(d));
>
>
> --
> http://bernd.eckenfels.net
>
More information about the core-libs-dev
mailing list