javacalendarlocaledayofweek

Calendar#getFirstDayOfWeek() returns wrong value


I might be overlooking something incredible obvious, but why does this:

final Calendar calendar = Calendar.getInstance(Locale.GERMAN);
System.out.println(calendar.getFirstDayOfWeek());

Result in

1  (Sunday)

instead of

2 (Monday)

?

And before someone claims "the first day of the week is Sunday for all German speaking people" (again), it's not: "[D] is the weekday number, from 1 through 7, beginning with Monday and ending with Sunday."

In fact, Locale.GERMANY results in the correct "Monday".

Why would the first day of the week be Sunday for a German locale?


Solution

  • All default locales for a specific language e.g. Locale.GERMAN, Locale.FRENCH, Locale.ENGLISH default the not specified part of the locale to USA. Effectively these constant represent a German, French or English speaking person living in the USA.

    There is probably no good answer to this question because knowing just the language is not enough to figure out the first day of a week. Maybe because Java was developed by a USA company for US market the default locale values are using USA as a country.

    If you need a German locale use Locale.GERMANY as pointed out by the other answer.