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