Calendar (Java SE 25 & JDK 25)
- All Implemented Interfaces:
Serializable, Cloneable, Comparable<Calendar>
- Direct Known Subclasses:
GregorianCalendar
-
Nested Class Summary
Nested Classes
static classCalendar.Builderis used for creating aCalendarfrom various date-time parameters. -
Field Summary
Fields
static final intA style specifier for
getDisplayNamesindicating names in all styles, such as "January" and "Jan".static final intValue of the
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
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
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
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
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 intValue of the
DAY_OF_WEEKfield indicating Friday.static 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
MONTHfield indicating the first month of the year in the Gregorian and Julian calendars.static final intValue of the
MONTHfield indicating the seventh month of the year in the Gregorian and Julian calendars.static final intValue of the
MONTHfield indicating the sixth month of the year in the Gregorian and Julian calendars.static final intA style specifier for
getDisplayNameandgetDisplayNamesequivalent toLONG_FORMAT.static final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a long name used for format.static final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a long name used independently, such as a month name as calendar headers.static final intValue of the
MONTHfield indicating the third month of the year in the Gregorian and Julian calendars.static final intValue of the
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 intValue of the
DAY_OF_WEEKfield indicating Monday.static final intField number for
getandsetindicating the month.static final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a narrow name used for format.static final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a narrow name independently.static final intValue of the
MONTHfield indicating the eleventh month of the year in the Gregorian and Julian calendars.static final intValue of the
MONTHfield indicating the tenth month of the year in the Gregorian and Julian calendars.static final intValue of the
AM_PMfield indicating the period of the day from noon to just before midnight.static final intValue of the
DAY_OF_WEEKfield indicating Saturday.static final intField number for
getandsetindicating the second within the minute.static final intValue of the
MONTHfield indicating the ninth month of the year in the Gregorian and Julian calendars.static final intA style specifier for
getDisplayNameandgetDisplayNamesequivalent toSHORT_FORMAT.static final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a short name used for format.static final intA style specifier for
getDisplayNameandgetDisplayNamesindicating a short name used independently, such as a month abbreviation as calendar headers.static final intValue of the
DAY_OF_WEEKfield indicating Sunday.static final intValue of the
DAY_OF_WEEKfield indicating Thursday.protected longThe currently set time for this calendar, expressed in milliseconds after January 1, 1970, 0:00:00 GMT.
static final intValue of the
DAY_OF_WEEKfield indicating Tuesday.static final intValue of the
MONTHfield indicating the thirteenth month of the year.static final intValue of the
DAY_OF_WEEKfield indicating Wednesday.static 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
-
Method Summary
abstract voidadd(int field, int amount) Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules.
booleanReturns 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 voidclear()Sets all the calendar field values and the time value (millisecond offset from the Epoch) of this
Calendarundefined.final voidclear(int field) Sets the given calendar field value and the time value (millisecond offset from the Epoch) of this
Calendarundefined.clone()Creates and returns a copy of this object.
intCompares the time values (millisecond offsets from the Epoch) represented by two
Calendarobjects.protected voidcomplete()Fills in any unset fields in the calendar fields.
protected abstract voidprotected abstract voidbooleanCompares this
Calendarto the specifiedObject.intget(int field) Returns the value of the given calendar field.
intgetActualMaximum(int field) Returns the maximum value that the specified calendar field could have, given the time value of this
Calendar.intgetActualMinimum(int field) Returns the minimum value that the specified calendar field could have, given the time value of this
Calendar.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 calendar type of this
Calendar.getDisplayName(int field, int style, Locale locale) Returns the string representation of the calendar
fieldvalue in the givenstyleandlocale.getDisplayNames(int field, int style, Locale locale) 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.abstract intgetGreatestMinimum(int field) Returns the highest minimum value for the given calendar field of this
Calendarinstance.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.
abstract intgetLeastMaximum(int field) Returns the lowest maximum value for the given calendar field of this
Calendarinstance.abstract intgetMaximum(int field) Returns the maximum value for the given calendar field of this
Calendarinstance.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.
abstract intgetMinimum(int field) Returns the minimum value for the given calendar field of this
Calendarinstance.getTime()Returns a
Dateobject representing thisCalendar's time value (millisecond offset from the Epoch").longReturns this Calendar's time value in milliseconds.
intReturns the number of weeks in the week year represented by this
Calendar.intReturns the week year represented by this
Calendar.inthashCode()Returns a hash code for this calendar.
protected final intinternalGet(int field) Returns the value of the given calendar field.
booleanTells whether date/time interpretation is to be lenient.
final booleanisSet(int field) Determines 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.booleanReturns whether this
Calendarsupports week dates.abstract 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 the specified (signed) amount to the specified calendar field without changing larger fields.
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.voidsetFirstDayOfWeek(int value) Sets what the first day of the week is; e.g.,
SUNDAYin the U.S.,MONDAYin France.voidsetLenient(boolean lenient) Specifies whether or not date/time interpretation is to be lenient.
voidsetMinimalDaysInFirstWeek(int value) Sets 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.voidsetTimeInMillis(long millis) Sets this Calendar's current time from the given long value.
voidSets the time zone with the given time zone value.
voidsetWeekDate(int weekYear, int weekOfYear, int dayOfWeek) Sets the date of this
Calendarwith the given date specifiers - week year, week of year, and day of week.Converts this object to an
Instant.toString()Return a string representation of this calendar.
-
Field Details
-
ERA
-
YEAR
-
MONTH
-
WEEK_OF_YEAR
-
WEEK_OF_MONTH
-
DATE
-
DAY_OF_MONTH
-
DAY_OF_YEAR
-
DAY_OF_WEEK
-
DAY_OF_WEEK_IN_MONTH
-
AM_PM
-
HOUR
-
HOUR_OF_DAY
-
MINUTE
-
SECOND
-
MILLISECOND
-
ZONE_OFFSET
-
DST_OFFSET
-
FIELD_COUNT
-
SUNDAY
-
MONDAY
-
TUESDAY
-
WEDNESDAY
-
THURSDAY
-
FRIDAY
-
SATURDAY
-
JANUARY
-
FEBRUARY
-
MARCH
-
APRIL
-
MAY
-
JUNE
-
JULY
-
AUGUST
-
SEPTEMBER
-
OCTOBER
-
NOVEMBER
-
DECEMBER
-
UNDECIMBER
-
AM
-
PM
-
ALL_STYLES
-
SHORT
-
LONG
-
NARROW_FORMAT
-
NARROW_STANDALONE
-
SHORT_FORMAT
-
LONG_FORMAT
-
SHORT_STANDALONE
-
LONG_STANDALONE
-
fields
-
isSet
-
time
-
isTimeSet
-
areFieldsSet
-
-
Constructor Details
-
Calendar
-
Calendar
-
-
Method Details
-
getInstance
-
getInstance
-
getInstance
-
getInstance
-
getAvailableLocales
-
computeTime
-
computeFields
-
getTime
-
setTime
-
getTimeInMillis
-
setTimeInMillis
-
get
-
internalGet
-
set
-
set
-
set
-
set
-
clear
-
clear
-
isSet
-
getDisplayName
-
getDisplayNames
-
complete
-
getAvailableCalendarTypes
-
getCalendarType
-
equals
-
hashCode
-
before
-
after
-
compareTo
-
add
-
roll
-
roll
-
setTimeZone
-
getTimeZone
-
setLenient
-
isLenient
-
setFirstDayOfWeek
-
getFirstDayOfWeek
-
setMinimalDaysInFirstWeek
-
getMinimalDaysInFirstWeek
-
isWeekDateSupported
-
getWeekYear
-
setWeekDate
-
getWeeksInWeekYear
-
getMinimum
-
getMaximum
-
getGreatestMinimum
-
getLeastMaximum
-
getActualMinimum
-
getActualMaximum
-
clone
-
toString
-
toInstant
-