Java java.util Calendar fields, constructors, methods, implement or subclass

Example usage for Java java.util Calendar fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util Calendar.

The text is from its open source code.

Field

intERA
Field number for get and set indicating the era, e.g., AD or BC in the Julian calendar.
intYEAR
Field number for get and set indicating the year.
intMONTH
Field number for get and set indicating the month.
intWEEK_OF_YEAR
Field number for get and set indicating the week number within the current year.
intWEEK_OF_MONTH
Field number for get and set indicating the week number within the current month.
intDATE
Field number for get and set indicating the day of the month.
intDAY_OF_MONTH
Field number for get and set indicating the day of the month.
intDAY_OF_YEAR
Field number for get and set indicating the day number within the current year.
intDAY_OF_WEEK
Field number for get and set indicating the day of the week.
intDAY_OF_WEEK_IN_MONTH
Field number for get and set indicating the ordinal number of the day of the week within the current month.
intAM_PM
Field number for get and set indicating whether the HOUR is before or after noon.
intHOUR
Field number for get and set indicating the hour of the morning or afternoon.
intHOUR_OF_DAY
Field number for get and set indicating the hour of the day.
intMINUTE
Field number for get and set indicating the minute within the hour.
intSECOND
Field number for get and set indicating the second within the minute.
intMILLISECOND
Field number for get and set indicating the millisecond within the second.
intZONE_OFFSET
Field number for get and set indicating the raw offset from GMT in milliseconds.
intDST_OFFSET
Field number for get and set indicating the daylight saving offset in milliseconds.
intSUNDAY
Value of the #DAY_OF_WEEK field indicating Sunday.
intMONDAY
Value of the #DAY_OF_WEEK field indicating Monday.
intTUESDAY
Value of the #DAY_OF_WEEK field indicating Tuesday.
intWEDNESDAY
Value of the #DAY_OF_WEEK field indicating Wednesday.
intTHURSDAY
Value of the #DAY_OF_WEEK field indicating Thursday.
intFRIDAY
Value of the #DAY_OF_WEEK field indicating Friday.
intSATURDAY
Value of the #DAY_OF_WEEK field indicating Saturday.
intJANUARY
Value of the #MONTH field indicating the first month of the year in the Gregorian and Julian calendars.
intFEBRUARY
Value of the #MONTH field indicating the second month of the year in the Gregorian and Julian calendars.
intMARCH
Value of the #MONTH field indicating the third month of the year in the Gregorian and Julian calendars.
intAPRIL
Value of the #MONTH field indicating the fourth month of the year in the Gregorian and Julian calendars.
intMAY
Value of the #MONTH field indicating the fifth month of the year in the Gregorian and Julian calendars.
intJUNE
Value of the #MONTH field indicating the sixth month of the year in the Gregorian and Julian calendars.
intJULY
Value of the #MONTH field indicating the seventh month of the year in the Gregorian and Julian calendars.
intAUGUST
Value of the #MONTH field indicating the eighth month of the year in the Gregorian and Julian calendars.
intSEPTEMBER
Value of the #MONTH field indicating the ninth month of the year in the Gregorian and Julian calendars.
intOCTOBER
Value of the #MONTH field indicating the tenth month of the year in the Gregorian and Julian calendars.
intNOVEMBER
Value of the #MONTH field indicating the eleventh month of the year in the Gregorian and Julian calendars.
intDECEMBER
Value of the #MONTH field indicating the twelfth month of the year in the Gregorian and Julian calendars.
intUNDECIMBER
Value of the #MONTH field indicating the thirteenth month of the year.
intAM
Value of the #AM_PM field indicating the period of the day from midnight to just before noon.
intPM
Value of the #AM_PM field indicating the period of the day from noon to just before midnight.
intALL_STYLES
A style specifier for #getDisplayNames(int,int,Locale) getDisplayNames indicating names in all styles, such as "January" and "Jan".
intSHORT
A style specifier for #getDisplayName(int,int,Locale) getDisplayName and #getDisplayNames(int,int,Locale) getDisplayNames equivalent to #SHORT_FORMAT .
intLONG
A style specifier for #getDisplayName(int,int,Locale) getDisplayName and #getDisplayNames(int,int,Locale) getDisplayNames equivalent to #LONG_FORMAT .
intSHORT_FORMAT
A style specifier for #getDisplayName(int,int,Locale) getDisplayName and #getDisplayNames(int,int,Locale) getDisplayNames indicating a short name used for format.
booleanisSet
The flags which tell if a specified calendar field for the calendar is set.

Method

voidadd(int field, int amount)
Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules.
booleanafter(Object when)
Returns whether this Calendar represents a time after the time represented by the specified Object.
booleanbefore(Object when)
Returns whether this Calendar represents a time before the time represented by the specified Object.
voidclear()
Sets all the calendar field values and the time value (millisecond offset from the Epoch) of this Calendar undefined.
voidclear(int field)
Sets the given calendar field value and the time value (millisecond offset from the Epoch) of this Calendar undefined.
Objectclone()
Creates and returns a copy of this object.
intcompareTo(Calendar anotherCalendar)
Compares the time values (millisecond offsets from the Epoch) represented by two Calendar objects.
intcompareTo(long t)
booleanequals(Object obj)
Compares this Calendar to the specified Object.
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.
ClassgetClass()
Returns the runtime class of this Object .
StringgetDisplayName(int field, int style, Locale locale)
Returns the string representation of the calendar field value in the given style and locale.
MapgetDisplayNames(int field, int style, Locale locale)
Returns a Map containing all names of the calendar field in the given style and locale and their corresponding field values.
intgetFirstDayOfWeek()
Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
intgetGreatestMinimum(int field)
Returns the highest minimum value for the given calendar field of this Calendar instance.
CalendargetInstance()
Gets a calendar using the default time zone and locale.
CalendargetInstance(TimeZone zone)
Gets a calendar using the specified time zone and default locale.
CalendargetInstance(Locale aLocale)
Gets a calendar using the default time zone and specified locale.
CalendargetInstance(TimeZone zone, Locale aLocale)
Gets a calendar with the specified time zone and locale.
intgetLeastMaximum(int field)
Returns the lowest maximum value for the given calendar field of this Calendar instance.
intgetMaximum(int field)
Returns the maximum value for the given calendar field of this Calendar instance.
intgetMinimalDaysInFirstWeek()
Gets 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.
intgetMinimum(int field)
Returns the minimum value for the given calendar field of this Calendar instance.
DategetTime()
Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").
longgetTimeInMillis()
Returns this Calendar's time value in milliseconds.
TimeZonegetTimeZone()
Gets the time zone.
intgetWeeksInWeekYear()
Returns the number of weeks in the week year represented by this Calendar .
intgetWeekYear()
Returns the week year represented by this Calendar .
inthashCode()
Returns a hash code for this calendar.
booleanisLenient()
Tells whether date/time interpretation is to be lenient.
booleanisWeekDateSupported()
Returns whether this Calendar supports 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 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.
voidset(int year, int month, int date)
Sets the values for the calendar fields YEAR, MONTH, and DAY_OF_MONTH.
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, and MINUTE.
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, and SECOND.
voidsetFirstDayOfWeek(int value)
Sets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in 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.
voidsetTime(Date date)
Sets this Calendar's time with the given Date.
voidsetTimeInMillis(long millis)
Sets this Calendar's current time from the given long value.
voidsetTimeZone(TimeZone value)
Sets the time zone with the given time zone value.
voidsetWeekDate(int weekYear, int weekOfYear, int dayOfWeek)
Sets the date of this Calendar with the given date specifiers - week year, week of year, and day of week.
InstanttoInstant()
Converts this object to an Instant .
StringtoString()
Return a string representation of this calendar.