Canlendar 日期类
Canlendar的构造方法
canlendar 是一个抽象类,通过getInstance获取子类的对象(多态)
Calendar calendar = Calendar.getInstance();
Canlendar的get和set方法
GET
canlendar中的静态常量
public static final int YEAR = 1;
public static final int WEEK_OF_YEAR = 3;
public static final int WEEK_OF_MONTH = 4;
public static final int DATE = 5;
public static final int DAY_OF_MONTH = 5;
public static final int DAY_OF_YEAR = 6;
public static final int DAY_OF_WEEK = 7;
....
canlendar的get方法field对应静态常量的值
public int get(int field);
canlendar的set方法
public class CanlenderDemo {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();// 通过getInstance获取日历对象
System.out.println(calendar);
calendar.get(Calendar.YEAR);
calendar.get(Calendar.MONTH);
calendar.get(Calendar.DATE);
calendar.set(Calendar.YEAR,2000);
calendar.set(2020,1,10);
}
}