For a java application the week number is important to the end user. However for some reason for the same date and locale the week numbers differ between my machine and that of the end user.
We both run Windows 10 64bit and jre1.8.0_101
I created a small program to illustrate the problem, and it yields different results between both machines.
Calendar calUs = Calendar.getInstance(Locale.US);
String usToday = "this week US: \t\t\t" + calUs.get(Calendar.WEEK_OF_YEAR) + " (should be 35 on 24-8-2016)";
Calendar calDe = Calendar.getInstance(Locale.GERMAN);
String deToday = "this week DE: \t\t\t" + calDe.get(Calendar.WEEK_OF_YEAR) + " (should be 34 on 24-8-2016)";
Calendar calDef = Calendar.getInstance();
String defToday = "this week default default: \t" + calDef.get(Calendar.WEEK_OF_YEAR)
+ " (should be 34 on 24-8-2016)";
System.out.println("Default locale: " + Locale.getDefault() + "\t(should be nl_NL)");
System.out.println(usToday);
System.out.println(deToday);
System.out.println(defToday);
On my machine this yields:
Default locale: nl_NL (should be nl_NL)
this week US: 35 (should be 35 on 24-8-2016)
this week DE: 34 (should be 34 on 24-8-2016)
this week default default: 34 (should be 34 on 24-8-2016)
But for the end user we see the wrong results:
Default locale: nl_NL (should be nl_NL)
this week US: 35 (should be 35 on 24-8-2016)
this week DE: 35 (should be 34 on 24-8-2016)
this week default default: 35 (should be 34 on 24-8-2016)
I already tried changing the first day of week and first week of year settings in the windows registry to try and reproduce the issue, without success. In MS Outlook we get the correct week number on both machines. This leads me to believe that the problem is restricted to java somehow.
What am I missing here?