<i18n dev> Defaulting Week Fields behaviour to ISO standard
Przemyslaw Gomulka
p.gomulka at hotmail.com
Wed Jan 22 13:37:25 UTC 2020
Hello,
I am not sure this is the right place to ask, but I couldn't find answers anywhere else.
I want my application to parse and format dates basing on start of the week being Monday and requiring 4days in the first week of the year.
This was the behaviour existing previously in joda.org library, but seems like this was now defaulted to start of the week Sunday and requires only 1day of the week - looks like basing on US locale
I understand that I can specify a locale and this will allow me to parse my dates with these rules.
However I have planty of formatters where I cannot tell what locale should be used, and wanted to use Locale.ROOT which sadly defaults to Sunday,1.
I can workaround this with unicode extension “fw” for Locale.ROOT and default to “sun”. I can’t find the extension for minimal days in the first week.
Loading a custom CalendarDataProvider works for me, but relies on a my Custom implementation to be present on a classpath.
Both workarounds were introduced in JDK9.
JDK8 do not allow me to load SPI implementation from a classpath - requires these classes to be placed in a jar in jre/lib/ext. Unfortunately I cannot control what a user of the application will have in their JRE. It would be great if https://bugs-stage.openjdk.java.net/browse/JDK-8167324 was also backported to 8.
--
How can I work around in JDK8? Is there any other preferred way to achieve this?
--
What was the reasoning to default to Sunday,1 ? I think it was incorrectly assumed that this is common. As per incorrect in my opinion javadoc in java.time.temporal.WeekFields.java:222 (jdk12)
* This week definition is in use in the US and other European countries.
*/
public static final WeekFields SUNDAY_START = WeekFields.of(DayOfWeek.SUNDAY, 1);
Thank you
Przemek Gomulka
More information about the i18n-dev
mailing list