美文网首页
Calendar 获取周几

Calendar 获取周几

作者: 茶瓯 | 来源:发表于2018-04-19 11:35 被阅读0次
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;

/**
 * Value of the {@link #DAY_OF_WEEK} field indicating
 * Wednesday.
 */
public final static int WEDNESDAY = 4;

Calendar已经默认SUNDAY为1

    int o = calendar.get(Calendar.DAY_OF_WEEK);
    if (o == Calendar.SUNDAY) {
        int dayOfWeek = 7;
    } else {
        int dayOfWeek = o - 1;
    }

//设置一周开始的计算方式
calendar.setFirstDayOfWeek(Calendar.MONDAY);

相关文章

网友评论

      本文标题:Calendar 获取周几

      本文链接:https://www.haomeiwen.com/subject/fyxwkftx.html