java获取天数和周数
2017-11-15 本文已影响0人
Bruce杨
package com.example.demo;
import java.util.Calendar;
public class Test {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, 2017); // 2017年
c.set(Calendar.MONTH, 10); // 11 月
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));
}
}