获取当前 int 星期几加一
Get current int day of week is increased by one
我必须将当前星期几作为整数,我正在使用 Calendar
但我得到它增加了一个,为什么?
Calendar c = Calendar.getInstance();
c.setTime(new Date());
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
它 returns 3 表示今天是星期二,而不是 2。
值是这样的:
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7
您可以这样查看:
System.out.println(Calendar.SUNDAY);
值定义在 java.util.Calendar
class:
/**
* 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;
我必须将当前星期几作为整数,我正在使用 Calendar
但我得到它增加了一个,为什么?
Calendar c = Calendar.getInstance();
c.setTime(new Date());
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
它 returns 3 表示今天是星期二,而不是 2。
值是这样的:
Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7
您可以这样查看:
System.out.println(Calendar.SUNDAY);
值定义在 java.util.Calendar
class:
/**
* 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;