java Calendar setFirstDayOfWeek not working

后端 未结 3 613
不知归路
不知归路 2020-12-19 11:36

Here is the real calendar now:

   March 2015       
Su Mo Tu We Th Fr Sa  
 1  2  3  4  5  6  7  
 8  9 10 11 12 13 14  
15 16 17 18 19 20 2         


        
3条回答
  •  孤城傲影
    2020-12-19 12:14

    cal.get(Calendar.DAY_OF_WEEK) will return you which day it is (SUNDAY, MONDAY, etc...) for the given date. So it will return you TUESDAY and then 3, whatever the first day of week is. This has nothing to do with the setFirstDayOfWeek method.

    If you want to compute the number of day since the beginning of the week, you just have to get the first day of the week using getFirstDayOfWeek and do some simple math.

提交回复
热议问题