For a java application, the week number is important to the end user. However, for any reason, the week numbers on the same date and locale are different between my machine and 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 gives 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 gives:
Default locale: nl_NL (must be nl_NL)
this week USA: 35 (should be 35 on 24-8-2016)
this week DE: 34 (should be 34 on 24-8-2016)
default value this week: 34 (should be 34 on 24-8-2016)
But for the end user, we see incorrect results:
Default locale: nl_NL (must be nl_NL)
this week USA: 35 (should be 35 on 24-8-2016)
this week DE: 35 (should be 34 on 24-8-2016)
default value this week: 35 (should be 34 on 24-8-2016)
I already tried to change the settings for the first day of the week and the first week in the Windows registry in order to try to reproduce the problem without success. In MS Outlook, we get the correct week number on both machines. This makes me think that the problem is somehow limited by java.
What am I missing here?
java
steveman
source share