我必须将当前的一周当作int并且我使用Calendar
,但我将它增加1,为什么?
Calendar c = Calendar.getInstance();
c.setTime(new Date());
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
今天是星期二,它返回3,而不是2。
答案 0 :(得分:5)
值如下:
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7
您可以这样检查:
System.out.println(Calendar.SUNDAY);
答案 1 :(得分:2)
值在java.util.Calendar
类中定义:
/**
* Value of the {@link #DAY_OF_WEEK} field indicating
* Sunday.
*/
public final static int SUNDAY = 1;
/**
* Value of the {@link #DAY_OF_WEEK} field indicating
* Monday.
*/
public final static int MONDAY = 2;
/**
* Value of the {@link #DAY_OF_WEEK} field indicating
* Tuesday.
*/
public final static int TUESDAY = 3;