Why can't Calendar.getInstance () use the standard locale?

Yesterday I received an answer to the question: WEEK_OF_YEAR are incompatible on different machines

(basically learned how WEEK_OF_YEAR is calculated based on firstDayOfWeek and minimumDaysInFirstWeek )

But now I have the following question: what other settings can affect the ability of the Calendar to use the standard locale? Because here is the behavior that I am observing (with the correct locale en_US by default):

Calendar c = Calendar.getInstance(); // should use the default locale, per docs System.out.println(c.getFirstDayOfWeek()); System.out.println(c.getMinimalDaysInFirstWeek()); c = Calendar.getInstance(Locale.getDefault()); // provide the default explicitly System.out.println(c.getFirstDayOfWeek()); System.out.println(c.getMinimalDaysInFirstWeek()); 

The result of work:

  • 2
  • 4
  • one
  • one

This looks even more absurd (setDefault for getDefault results ...?!) If I ran this in Clojure (JVM language, so the behavior is exactly the same):

 user=> (.getFirstDayOfWeek (java.util.Calendar/getInstance)) 2 user=> (Locale/setDefault (Locale/getDefault)) nil user=> (.getFirstDayOfWeek (java.util.Calendar/getInstance)) 1 

The above examples are executed without any JVM arguments, so, to my question, where can I set parameters 2 and 4 for firstDayOfWeek and minimumDaysInWeek? And, perhaps most importantly, how do I fix them forever?

Thanks!

+2
source share

All Articles