Gregorian Calendar Class
Categories: Java 8(JDK1.8)
GregorianCalendar is a concrete implementation of a Calendar class that implements the normal Gregorian calendar with which you are familiar. We did not discuss Calendar class in this tutorial, you can look up standard Java documentation for this.
The getInstance( ) method of Calendar returns a GregorianCalendar initialized with the current date and time in the default locale and time zone. GregorianCalendar defines two fields: AD and BC. These represent the two eras defined by the Gregorian calendar.
There are also several constructors for GregorianCalendar objects −
Sr.No.Constructor & Description
1 GregorianCalendar() - Constructs a default GregorianCalendar using the current time in the default time zone with the default locale.
2. GregorianCalendar(int year, int month, int date) - Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.
3. GregorianCalendar(int year, int month, int date, int hour, int minute) - Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.
4. GregorianCalendar(int year, int month, int date, int hour, int minute, int second) - Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.
5. GregorianCalendar(Locale aLocale) - Constructs a GregorianCalendar based on the current time in the default time zone with the given locale.