so I wanted to implement a method that gives me the dates of the workdays, and if it's Saturday or Sunday those of the next week. To achieve this I used Calendar and the setFirstDayOfWeek method. This is how my code looks:
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"));
calendar.setFirstDayOfWeek(Calendar.SATURDAY);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); //write to array
calendar.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);//write
calendar.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); // and so on...
If I compile this in IntelliJ on Sat. Dec 6, I get the following dates:
Mon Dec 08 23:44:32 CET 2014
Tue Dec 09 23:44:32 CET 2014
...
Sat Dec 06 23:44:32 CET 2014
Sun Dec 07 23:44:32 CET 2014
..just as it was intended. w/o setting the first day of week to Saturday the Monday date would be Dec 01.
Now I use the exact same code under Android Studio. The dates look like they do in IntelliJ if I don't set the first day of week to Saturday. Can anybody tell me why the same code provides different results?