判断当前时间为第几周,周几

private void getWeekAndDay(){
    Calendar calendar= Calendar.getInstance();
    //获取当前时间为本月的第几周
    int week = calendar.get(Calendar.WEEK_OF_MONTH);
    //获取当前时间为本周的第几天
    int day = calendar.get(Calendar.DAY_OF_WEEK);
    if (day==1) {
        day=7;
        week=week-1;
    } else {
        day=day-1;
    }
    System.out.println("今天是本月的第" + week + "周"+",星期"+(day));

}

你可能感兴趣的:(android)