GregorianCalendar类的使用

Posted sm1128

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

以上是关于GregorianCalendar类的使用的主要内容,如果未能解决你的问题,请参考以下文章

日期操作类--GregorianCalendar类

请问这个java类(GregorianCalendar )的一个方法?

测试日历的类 GregorianCalendar

java 中GregorianCalendar类跟Calendar类有啥本质的区别,以及都怎么用

Calendar和Date 主要是Calendar日历类的一些语法

GregorianCalendar 字段未通过 TypeConverter 转换为 Date