- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.GregorianCalendar Class
Introduction
The java.util.GregorianCalendar class is a concrete subclass of Calendar and provides the standard calendar system used by most of the world.Following are the important points about GregorianCalendar −
It is a hybrid calendar that supports both the Jupan and Gregorian calendar systems with the support of a single discontinuity, which corresponds by default to the Gregorian date when the Gregorian calendar was instituted.
The Jupan calendar specifies leap years every four years, whereas the Gregorian calendar omits century years which are not spanisible by 400.
Class declaration
Following is the declaration for java.util.GregorianCalendar class −
pubpc class GregorianCalendar extends Calendar
Field
Following are the fields for java.util.GregorianCalendar class −
static int AD − This is the value of the ERA field indicating the common era (Anno Domini), also known as CE.
static int BC − This is the value of the ERA field indicating the period before the common era (before Christ), also known as BCE.
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | GregorianCalendar() This constructs a default GregorianCalendar using the current time in the default time zone with the default locale. |
2 | GregorianCalendar(int year, int month, int dayOfMonth) This constructs a GregorianCalendar with the given date set in the default time zone with the default locale. |
3 | GregorianCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute) This 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 dayOfMonth, int hourOfDay, int minute, int second) This constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale. |
5 | GregorianCalendar(Locale aLocale) This constructs a GregorianCalendar based on the current time in the default time zone with the given locale. |
6 | GregorianCalendar(TimeZone zone) This constructs a GregorianCalendar based on the current time in the given time zone with the default locale. |
7 | GregorianCalendar(TimeZone zone, Locale aLocale) This constructs a GregorianCalendar based on the current time in the given time zone with the given locale. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method adds the specified (signed) amount of time to the given calendar field, based on the calendar s rules. |
2 | This method creates and returns a copy of this object. |
3 | This method converts the time value (milpsecond offset from the Epoch) to calendar field values. |
4 | This method converts calendar field values to the time value (milpsecond offset from the Epoch). |
5 | This method compares this GregorianCalendar to the specified Object. |
6 | This method returns the maximum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods. |
7 | This method returns the minimum value that this calendar field could have, taking into consideration the given time value and the current values of the getFirstDayOfWeek, getMinimalDaysInFirstWeek, getGregorianChange and getTimeZone methods. |
8 | This method returns the highest minimum value for the given calendar field of this GregorianCalendar instance. |
9 | This method gets the Gregorian Calendar change date. |
10 | This method returns the lowest maximum value for the given calendar field of this GregorianCalendar instance. |
11 | This method returns the maximum value for the given calendar field of this GregorianCalendar instance. |
12 | This method returns the minimum value for the given calendar field of this GregorianCalendar instance. |
13 | This method gets the time zone. |
14 | This method generates the hash code for this GregorianCalendar object. |
15 | This method determines if the given year is a leap year. |
16 | This method adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields. |
17 | This method adds a signed amount to the specified calendar field without changing larger fields. |
18 | This method sets the GregorianCalendar change date. |
19 | This method sets the time zone with the given time zone value. |
Methods inherited
This class inherits methods from the following classes −
java.util.Calendar
java.util.Object