GregorianCalendar类的使用

Calendar与GregorianCalendar是父子关系,Calendar是父类.

Calendar日历类

GregorianCalendar类用法 对日期的年月日等进行加减

public class GregorianCalendarTest {
	public static void main(String[] args) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		GregorianCalendar cal = new GregorianCalendar();
		Date date = new Date();
		System.out.println(sdf.format(date));
		cal.setTime(date);
		cal.add(1, 1);
		Date time = cal.getTime();
		System.out.println(sdf.format(time));
	}
}
2019-12-06
2020-12-06
public final static int YEAR = 1;
public final static int MONTH = 2;
public final static int WEEK_OF_YEAR = 3;
public final static int WEEK_OF_MONTH = 4;
public final static int DATE = 5;
public final static int DAY_OF_MONTH = 5;
public final static int DAY_OF_YEAR = 6;
public final static int DAY_OF_WEEK = 7;
public final static int DAY_OF_WEEK_IN_MONTH = 8;
public final static int AM_PM = 9;
public final static int HOUR = 10;
public final static int HOUR_OF_DAY = 11;
public final static int MINUTE = 12;
public final static int SECOND = 13;
public final static int MILLISECOND = 14;
public final static int ZONE_OFFSET = 15;
。。。。。
Calendar
posted @ 2019-12-06 11:52  等不到时光等天亮  阅读(2791)  评论(0编辑  收藏  举报