Just setting the day of the week seems unreliable. Consider the following simple code:
Calendar calendar = Calendar.getInstance(Locale.GERMANY); calendar.set(2011, Calendar.SEPTEMBER, 18); System.out.printf("Starting day: %tF%n", calendar); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); System.out.printf("Last monday: %tF%n", calendar); System.out.printf("First day of week: %d%n", calendar.getFirstDayOfWeek());
The result of starting this program is:
Starting day: 2011-09-18 Last monday: 2011-09-19 First day of week: 2
In other words, he stepped forward in time. For German, this is really not the expected answer. Please note that the calendar correctly uses Monday as the first day of the week (perhaps only for calculating the week of the year).
Michael Piefel Sep 21 2018-11-11T00: 00Z
source share