计算某月的天数和周数

public static void main(String[] args) throws ParseException {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, 2017); // 2010年
    c.set(Calendar.MONTH, 3); // 6 月
    System.out.println("------------" + c.get(Calendar.YEAR) + "年" + (c.get(Calendar.MONTH) + 1) + "月的天数和周数-------------");
    System.out.println("天数:" + c.getActualMaximum(Calendar.DAY_OF_MONTH));
    System.out.println("周数:" + c.getActualMaximum(Calendar.WEEK_OF_MONTH));
}

posted @ 2017-04-05 09:41  baby孔祥超  阅读(213)  评论(0编辑  收藏  举报