GregorianCalendar (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Serializable, Cloneable, Comparable<Calendar>
-
Nested Class Summary
Nested classes/interfaces declared in class Calendar
static classCalendar.Builderis used for creating aCalendarfrom various date-time parameters. -
Field Summary
Fields
static final intValue of the
ERAfield indicating the common era (Anno Domini), also known as CE.static final intValue of the
ERAfield indicating the period before the common era (before Christ), also known as BCE.Fields declared in class Calendar
ALL_STYLES, AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSETstatic final intA style specifier for
getDisplayNamesindicating names in all styles, such as "January" and "Jan".static final intValue of the
Calendar.AM_PMfield indicating the period of the day from midnight to just before noon.static final intField number for
getandsetindicating whether theHOURis before or after noon.static final intValue of the
Calendar.MONTHfield indicating the fourth month of the year in the Gregorian and Julian calendars.protected booleanTrue if
fields[]are in sync with the currently set time.static final intValue of the
Calendar.MONTHfield indicating the eighth month of the year in the Gregorian and Julian calendars.static final intField number for
getandsetindicating the day of the month.static final intField number for
getandsetindicating the day of the month.static final intField number for
getandsetindicating the day of the week.static final intField number for
getandsetindicating the ordinal number of the day of the week within the current month.static final intField number for
getandsetindicating the day number within the current year.static final intValue of the
Calendar.MONTHfield indicating the twelfth month of the year in the Gregorian and Julian calendars.static final intField number for
getandsetindicating the daylight saving offset in milliseconds.static final intField number for
getandsetindicating the era, e.g., AD or BC in the Julian calendar.static final intValue of the
Calendar.MONTHfield indicating the second month of the year in the Gregorian and Julian calendars.static final intThe number of distinct fields recognized by
getandset.protected int[]The calendar field values for the currently set time for this calendar.
static final intstatic final intField number for
getandsetindicating the hour of the morning or afternoon.static final intField number for
getandsetindicating the hour of the day.protected boolean[]The flags which tell if a specified calendar field for the calendar is set.
protected booleanTrue if then the value of
timeis valid.static final intValue of the
Calendar.MONTHfield indicating the first month of the year in the Gregorian and Julian calendars.static final intValue of the
Calendar.MONTHfield indicating the seventh month of the year in the Gregorian and Julian calendars.static final intValue of the
Calendar.MONTHfield indicating the sixth month of the year in the Gregorian and Julian calendars.static final intstatic final intstatic final intstatic final intValue of the
Calendar.MONTHfield indicating the third month of the year in the Gregorian and Julian calendars.static final intValue of the
Calendar.MONTHfield indicating the fifth month of the year in the Gregorian and Julian calendars.static final intField number for
getandsetindicating the millisecond within the second.static final intField number for
getandsetindicating the minute within the hour.static final intstatic final intField number for
getandsetindicating the month.static final intstatic final intstatic final intValue of the
Calendar.MONTHfield indicating the eleventh month of the year in the Gregorian and Julian calendars.static final intValue of the
Calendar.MONTHfield indicating the tenth month of the year in the Gregorian and Julian calendars.static final intValue of the
Calendar.AM_PMfield indicating the period of the day from noon to just before midnight.static final intstatic final intField number for
getandsetindicating the second within the minute.static final intValue of the
Calendar.MONTHfield indicating the ninth month of the year in the Gregorian and Julian calendars.static final intstatic final intstatic final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a short name used independently, such as a month abbreviation as calendar headers.static final intstatic final intprotected longThe currently set time for this calendar, expressed in milliseconds after January 1, 1970, 0:00:00 GMT.
static final intstatic final intValue of the
Calendar.MONTHfield indicating the thirteenth month of the year.static final intstatic final intField number for
getandsetindicating the week number within the current month.static final intField number for
getandsetindicating the week number within the current year.static final intField number for
getandsetindicating the year.static final intField number for
getandsetindicating the raw offset from GMT in milliseconds. -
Constructor Summary
Constructors
Constructs a default
GregorianCalendarusing the current time in the default time zone with the defaultFORMATlocale.GregorianCalendar(int year, int month, int dayOfMonth) Constructs a
GregorianCalendarwith the given date set in the default time zone with the default locale.GregorianCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute) Constructs a
GregorianCalendarwith the given date and time set for the default time zone with the default locale.GregorianCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute, int second) Constructs a GregorianCalendar with the given date and time set for the default time zone with the default locale.
Constructs a
GregorianCalendarbased on the current time in the default time zone with the given locale.Constructs a
GregorianCalendarbased on the current time in the given time zone with the defaultFORMATlocale.Constructs a
GregorianCalendarbased on the current time in the given time zone with the given locale. -
Method Summary
voidadd(int field, int amount) Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.
protected voidConverts the time value (millisecond offset from the Epoch) to calendar field values.
protected voidConverts calendar field values to the time value (millisecond offset from the Epoch).
booleanCompares this
GregorianCalendarto the specifiedObject.Obtains an instance of
GregorianCalendarwith the default locale from aZonedDateTimeobject.intgetActualMaximum(int field) intgetActualMinimum(int field) Returns
"gregory"as the calendar type.intgetGreatestMinimum(int field) Returns the highest minimum value for the given calendar field of this
GregorianCalendarinstance.Gets the Gregorian Calendar change date.
intgetLeastMaximum(int field) Returns the lowest maximum value for the given calendar field of this
GregorianCalendarinstance.intgetMaximum(int field) Returns the maximum value for the given calendar field of this
GregorianCalendarinstance.intgetMinimum(int field) Returns the minimum value for the given calendar field of this
GregorianCalendarinstance.intReturns the number of weeks in the week year represented by this
GregorianCalendar.intReturns the week year represented by this
GregorianCalendar.inthashCode()Generates the hash code for this
GregorianCalendarobject.booleanisLeapYear(int year) Determines if the given year is a leap year.
final booleanReturns
trueindicating thisGregorianCalendarsupports week dates.voidroll(int field, boolean up) Adds or subtracts (up/down) a single unit of time on the given time field without changing larger fields.
voidroll(int field, int amount) Adds a signed amount to the specified calendar field without changing larger fields.
voidSets the
GregorianCalendarchange date.voidsetWeekDate(int weekYear, int weekOfYear, int dayOfWeek) Sets this
GregorianCalendarto the date given by the date specifiers -weekYear,weekOfYear, anddayOfWeek.Converts this object to a
ZonedDateTimethat represents the same point on the time-line as thisGregorianCalendar.Methods declared in class Calendar
after, before, clear, clear, clone, compareTo, complete, get, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, getTimeZone, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, setTimeZone, toInstant, toStringbooleanReturns whether this
Calendarrepresents a time after the time represented by the specifiedObject.booleanReturns whether this
Calendarrepresents a time before the time represented by the specifiedObject.final voidSets all the calendar field values and the time value (millisecond offset from the Epoch) of this
Calendarundefined.final voidSets the given calendar field value and the time value (millisecond offset from the Epoch) of this
Calendarundefined.Creates and returns a copy of this object.
intCompares the time values (millisecond offsets from the Epoch) represented by two
Calendarobjects.protected voidFills in any unset fields in the calendar fields.
intget(int field) Returns the value of the given calendar field.
Returns an unmodifiable
Setcontaining all calendar types supported byCalendarin the runtime environment.Returns an array of all locales for which the
getInstancemethods of this class can return localized instances.Returns the string representation of the calendar
fieldvalue in the givenstyleandlocale.Returns a
Mapcontaining all names of the calendarfieldin the givenstyleandlocaleand their corresponding field values.intGets what the first day of the week is; e.g.,
SUNDAYin the U.S.,MONDAYin France.Gets a calendar using the default time zone and locale.
Gets a calendar using the default time zone and specified locale.
Gets a calendar using the specified time zone and default locale.
Gets a calendar with the specified time zone and locale.
intGets what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, this method returns 1.
Returns a
Dateobject representing thisCalendar's time value (millisecond offset from the Epoch").longReturns this Calendar's time value in milliseconds.
protected final intReturns the value of the given calendar field.
booleanTells whether date/time interpretation is to be lenient.
final booleanDetermines if the given calendar field has a value set, including cases that the value has been set by internal fields calculations triggered by a
getmethod call.voidset(int field, int value) Sets the given calendar field to the given value.
final voidset(int year, int month, int date) Sets the values for the calendar fields
YEAR,MONTH, andDAY_OF_MONTH.final voidset(int year, int month, int date, int hourOfDay, int minute) Sets the values for the calendar fields
YEAR,MONTH,DAY_OF_MONTH,HOUR_OF_DAY, andMINUTE.final voidset(int year, int month, int date, int hourOfDay, int minute, int second) Sets the values for the fields
YEAR,MONTH,DAY_OF_MONTH,HOUR_OF_DAY,MINUTE, andSECOND.voidSets what the first day of the week is; e.g.,
SUNDAYin the U.S.,MONDAYin France.voidSpecifies whether or not date/time interpretation is to be lenient.
voidSets what the minimal days required in the first week of the year are; For example, if the first week is defined as one that contains the first day of the first month of a year, call this method with value 1.
final voidSets this Calendar's time with the given
Date.voidSets this Calendar's current time from the given long value.
voidSets the time zone with the given time zone value.
Converts this object to an
Instant.Return a string representation of this calendar.
Methods declared in class Object
finalize, getClass, notify, notifyAll, wait, wait, waitprotected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
BC
-
AD
-
-
Constructor Details
-
GregorianCalendar
-
GregorianCalendar
-
GregorianCalendar
-
GregorianCalendar
-
GregorianCalendar
-
GregorianCalendar
-
GregorianCalendar
-
-
Method Details
-
setGregorianChange
-
getGregorianChange
-
isLeapYear
-
getCalendarType
-
equals
-
hashCode
-
add
-
roll
-
roll
-
getMinimum
-
getMaximum
-
getGreatestMinimum
-
getLeastMaximum
-
getActualMinimum
-
getActualMaximum
-
isWeekDateSupported
-
getWeekYear
-
setWeekDate
-
getWeeksInWeekYear
-
computeFields
-
computeTime
-
toZonedDateTime
-
from
-