Hjem

Java Calendar.WEEK_OF_DAY to start on a monday

Mads Fredrik Skoge Hoel

For some reason the Java Calendar.WEEK_OF_DAY starts on a SUNDAY regardless of locale or timezone. In some countries the week starts on a MONDAY. To work around this you can write:

 


Calendar c = Calendar.getInstance();
c.setTime(new Date());

int correctDay[] = {7, 1, 2, 3, 4, 5, 6};
System.out.println( c.get( correctDay[Calendar.DAY_OF_WEEK - 1] ) );