DthingApi
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
java.util.Calendar Class Referenceabstract
Inheritance diagram for java.util.Calendar:
java.io.Serializable java.util.GregorianCalendar

Public Member Functions

abstract void add (int field, int value)
 
boolean after (Object calendar)
 
boolean before (Object calendar)
 
final void clear ()
 
final void clear (int field)
 
Object clone ()
 
boolean equals (Object object)
 
int get (int field)
 
int getActualMaximum (int field)
 
int getActualMinimum (int field)
 
int getFirstDayOfWeek ()
 
abstract int getGreatestMinimum (int field)
 
abstract int getLeastMaximum (int field)
 
abstract int getMaximum (int field)
 
int getMinimalDaysInFirstWeek ()
 
abstract int getMinimum (int field)
 
final Date getTime ()
 
long getTimeInMillis ()
 
TimeZone getTimeZone ()
 
int hashCode ()
 
boolean isLenient ()
 
final boolean isSet (int field)
 
void roll (int field, int value)
 
abstract void roll (int field, boolean increment)
 
void set (int field, int value)
 
final void set (int year, int month, int day)
 
final void set (int year, int month, int day, int hourOfDay, int minute)
 
final void set (int year, int month, int day, int hourOfDay, int minute, int second)
 
void setFirstDayOfWeek (int value)
 
void setLenient (boolean value)
 
void setMinimalDaysInFirstWeek (int value)
 
final void setTime (Date date)
 
void setTimeInMillis (long milliseconds)
 
void setTimeZone (TimeZone timezone)
 
String toString ()
 

Static Public Member Functions

static synchronized Locale [] getAvailableLocales ()
 
static synchronized Calendar getInstance ()
 
static synchronized Calendar getInstance (Locale locale)
 
static synchronized Calendar getInstance (TimeZone timezone)
 
static synchronized Calendar getInstance (TimeZone timezone, Locale locale)
 

Static Public Attributes

static final int JANUARY = 0
 
static final int FEBRUARY = 1
 
static final int MARCH = 2
 
static final int APRIL = 3
 
static final int MAY = 4
 
static final int JUNE = 5
 
static final int JULY = 6
 
static final int AUGUST = 7
 
static final int SEPTEMBER = 8
 
static final int OCTOBER = 9
 
static final int NOVEMBER = 10
 
static final int DECEMBER = 11
 
static final int UNDECIMBER = 12
 
static final int SUNDAY = 1
 
static final int MONDAY = 2
 
static final int TUESDAY = 3
 
static final int WEDNESDAY = 4
 
static final int THURSDAY = 5
 
static final int FRIDAY = 6
 
static final int SATURDAY = 7
 
static final int ERA = 0
 
static final int YEAR = 1
 
static final int MONTH = 2
 
static final int WEEK_OF_YEAR = 3
 
static final int WEEK_OF_MONTH = 4
 
static final int DATE = 5
 
static final int DAY_OF_MONTH = 5
 
static final int DAY_OF_YEAR = 6
 
static final int DAY_OF_WEEK = 7
 
static final int DAY_OF_WEEK_IN_MONTH = 8
 
static final int AM_PM = 9
 
static final int HOUR = 10
 
static final int HOUR_OF_DAY = 11
 
static final int MINUTE = 12
 
static final int SECOND = 13
 
static final int MILLISECOND = 14
 
static final int ZONE_OFFSET = 15
 
static final int DST_OFFSET = 16
 
static final int FIELD_COUNT = 17
 
static final int AM = 0
 
static final int PM = 1
 
static final int ALL_STYLES = 0
 
static final int SHORT = 1
 
static final int LONG = 2
 

Protected Member Functions

 Calendar ()
 
 Calendar (TimeZone timezone, Locale locale)
 
void complete ()
 
abstract void computeFields ()
 
abstract void computeTime ()
 
final int internalGet (int field)
 

Protected Attributes

boolean areFieldsSet
 
int [] fields
 
boolean [] isSet
 
boolean isTimeSet
 
long time
 

Detailed Description

is an abstract base class for converting between a

Date

object and a set of integer fields such as

,

,

DAY

,

, and so on. (A

Date

object represents a specific instant in time with millisecond precision. See Date for information about the

Date

class.)

Subclasses of

interpret a

Date

according to the rules of a specific calendar system.

Like other locale-sensitive classes,

provides a class method,

, for getting a default instance of this class for general use.

's

method returns a calendar whose locale is based on system settings and whose time fields have been initialized with the current date and time:

Calendar rightNow = Calendar.getInstance()

A

object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).

defines the range of values returned by certain fields, as well as their meaning. For example, the first month of the year has value

==

for all calendars. Other values are defined by the concrete subclass, such as

and

. See individual field documentation and subclass documentation for details.

When a

is lenient, it accepts a wider range of field values than it produces. For example, a lenient

GregorianCalendar

interprets

==

,

== 32 as February 1. A non-lenient

GregorianCalendar

throws an exception when given out-of-range field settings. When calendars recompute field values for return by

get()

, they normalize them. For example, a

GregorianCalendar

always produces

values between 1 and the length of the month.

defines a locale-specific seven day week using two parameters: the first day of the week and the minimal days in first week (from 1 to 7). These numbers are taken from the locale resource data when a

is constructed. They may also be specified explicitly through the API.

When setting or getting the

or

fields,

must determine the first week of the month or year as a reference point. The first week of a month or year is defined as the earliest seven day period beginning on

and containing at least

days of that month or year. Weeks numbered ..., -1, 0 precede the first week; weeks numbered 2, 3,... follow it. Note that the normalized numbering returned by

get()

may be different. For example, a specific

subclass may designate the week before week 1 of a year as week n of the previous year.

When computing a

Date

from time fields, two special circumstances may arise: there may be insufficient information to compute the

Date

(such as only year and month but no day in the month), or there may be inconsistent information (such as "Tuesday, July 15, 1996" – July 15, 1996 is actually a Monday).

Insufficient information. The calendar will use default information to specify the missing fields. This may vary by calendar; for the Gregorian calendar, the default for a field is the same as that of the start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.

Inconsistent information. If fields conflict, the calendar will give preference to fields set more recently. For example, when determining the day, the calendar will look for one of the following combinations of fields. The most recent combination, as determined by the most recently set single field, will be used.

MONTH + DAY_OF_MONTH
MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
DAY_OF_YEAR
DAY_OF_WEEK + WEEK_OF_YEAR

For the time of day:

HOUR_OF_DAY
AM_PM + HOUR

Note: There are certain possible ambiguities in interpretation of certain singular times, which are resolved in the following ways:

  1. 24:00:00 "belongs" to the following day. That is, 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970 form a sequence of three consecutive minutes in time.

  2. Although historically not precise, midnight also belongs to "am", and noon belongs to "pm", so on the same day, we have 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm

The date or time format strings are not part of the definition of a calendar, as those must be modifiable or overridable by the user at runtime. Use java.text.DateFormat to format dates.

Field manipulation methods

fields can be changed using three methods:

set()

,

add()

, and

roll()

.

set(f, value)

changes field

f

to

value

. In addition, it sets an internal member variable to indicate that field

f

has been changed. Although field

f

is changed immediately, the calendar's milliseconds is not recomputed until the next call to

get()

,

, or

is made. Thus, multiple calls to

set()

do not trigger multiple, unnecessary computations. As a result of changing a field using

set()

, other fields may also change, depending on the field, the field value, and the calendar system. In addition,

get(f)

will not necessarily return

value

after the fields have been recomputed. The specifics are determined by the concrete calendar class.

Example: Consider a

GregorianCalendar

originally set to August 31, 1999. Calling set(Calendar.MONTH, Calendar.SEPTEMBER) sets the calendar to September 31, 1999. This is a temporary internal representation that resolves to October 1, 1999 if

is then called. However, a call to

set(Calendar.DAY_OF_MONTH, 30)

before the call to

sets the calendar to September 30, 1999, since no recomputation occurs after

set()

itself.

add(f, delta)

adds

delta

to field

f

. This is equivalent to calling set(f, get(f) + delta) with two adjustments:

Add rule 1. The value of field

f

after the call minus the value of field

f

before the call is

delta

, modulo any overflow that has occurred in field

f

. Overflow occurs when a field value exceeds its range and, as a result, the next larger field is incremented or decremented and the field value is adjusted back into its range.

Add rule 2. If a smaller field is expected to be invariant, but   it is impossible for it to be equal to its prior value because of changes in its minimum or maximum after field

f

is changed, then its value is adjusted to be as close as possible to its expected value. A smaller field represents a smaller unit of time.

is a smaller field than

. No adjustment is made to smaller fields that are not expected to be invariant. The calendar system determines what fields are expected to be invariant.

In addition, unlike

set()

,

add()

forces an immediate recomputation of the calendar's milliseconds and all fields.

Example: Consider a

GregorianCalendar

originally set to August 31, 1999. Calling

add(Calendar.MONTH, 13)

sets the calendar to September 30, 2000. Add rule 1 sets the

field to September, since adding 13 months to August gives September of the next year. Since

cannot be 31 in September in a

GregorianCalendar

, add rule 2 sets the

to 30, the closest possible value. Although it is a smaller field,

is not adjusted by rule 2, since it is expected to change when the month changes in a

GregorianCalendar

.

roll(f, delta)

adds

delta

to field

f

without changing larger fields. This is equivalent to calling

add(f, delta)

with the following adjustment:

Roll rule. Larger fields are unchanged after the call. A larger field represents a larger unit of time.

is a larger field than

.

Example: Consider a

GregorianCalendar

originally set to August 31, 1999. Calling roll(Calendar.MONTH, 8) sets the calendar to April 30, 1999. Add rule 1 sets the

field to April. Using a

GregorianCalendar

, the

cannot be 31 in the month April. Add rule 2 sets it to the closest possible value, 30. Finally, the roll rule maintains the

field value of 1999.

Example: Consider a

GregorianCalendar

originally set to Sunday June 6, 1999. Calling

roll(Calendar.WEEK_OF_MONTH, -1)

sets the calendar to Tuesday June 1, 1999, whereas calling

add(Calendar.WEEK_OF_MONTH, -1)

sets the calendar to Sunday May 30, 1999. This is because the roll rule imposes an additional constraint: The

must not change when the

is rolled. Taken together with add rule 1, the resultant date must be between Tuesday June 1 and Saturday June 5. According to add rule 2, the

, an invariant when changing the

, is set to Tuesday, the closest possible value to Sunday (where Sunday is the first day of the week).

Usage model. To motivate the behavior of

add()

and

roll()

, consider a user interface component with increment and decrement buttons for the month, day, and year, and an underlying

GregorianCalendar

. If the interface reads January 31, 1999 and the user presses the month increment button, what should it read? If the underlying implementation uses

set()

, it might read March 3, 1999. A better result would be February 28, 1999. Furthermore, if the user presses the month increment button again, it should read March 31, 1999, not March 28, 1999. By saving the original date and using either

add()

or

roll()

, depending on whether larger fields should be affected, the user interface can behave as most users will intuitively expect.

Note: You should always use

and

rather than attempting to perform arithmetic operations directly on the fields of a Calendar. It is quite possible for Calendar subclasses to have fields with non-linear behavior, for example missing months or days during non-leap years. The subclasses' add and roll methods will take this into account, while simple arithmetic manipulations may give invalid results.

See also
Date
GregorianCalendar
TimeZone

Constructor & Destructor Documentation

◆ Calendar() [1/2]

java.util.Calendar.Calendar ( )
inlineprotected

Constructs a

instance using the default

TimeZone

and

Locale

.

◆ Calendar() [2/2]

java.util.Calendar.Calendar ( TimeZone  timezone,
Locale  locale 
)
inlineprotected

Constructs a

instance using the specified

TimeZone

and

Locale

.

Parameters
timezonethe timezone.
localethe locale.

Member Function Documentation

◆ add()

abstract void java.util.Calendar.add ( int  field,
int  value 
)
abstract

Adds the specified amount to a

field.

Parameters
fieldthe field to modify.
valuethe amount to add to the field.
Exceptions
IllegalArgumentExceptionif
field
is or .

◆ after()

boolean java.util.Calendar.after ( Object  calendar)
inline

Returns whether the

Date

specified by this

instance is after the

Date

specified by the parameter. The comparison is not dependent on the time zones of the

.

Parameters
calendarthe instance to compare.
Returns
true
when this Calendar is after calendar,
false
otherwise.
Exceptions
IllegalArgumentExceptionif the time is not set and the time cannot be computed from the current field values.

◆ before()

boolean java.util.Calendar.before ( Object  calendar)
inline

Returns whether the

Date

specified by this

instance is before the

Date

specified by the parameter. The comparison is not dependent on the time zones of the

.

Parameters
calendarthe instance to compare.
Returns
true
when this Calendar is before calendar,
false
otherwise.
Exceptions
IllegalArgumentExceptionif the time is not set and the time cannot be computed from the current field values.

◆ clear() [1/2]

final void java.util.Calendar.clear ( )
inline

Clears all of the fields of this

. All fields are initialized to zero.

◆ clear() [2/2]

final void java.util.Calendar.clear ( int  field)
inline

Clears the specified field to zero and sets the isSet flag to

false

.

Parameters
fieldthe field to clear.

◆ clone()

Object java.util.Calendar.clone ( )
inline

Returns a new

with the same properties.

Returns
a shallow copy of this .
See also
java.lang.Cloneable

◆ complete()

void java.util.Calendar.complete ( )
inlineprotected

Computes the time from the fields if the time has not already been set. Computes the fields from the time if the fields are not already set.

Exceptions
IllegalArgumentExceptionif the time is not set and the time cannot be computed from the current field values.

◆ computeFields()

abstract void java.util.Calendar.computeFields ( )
abstractprotected

Computes the

fields from

.

◆ computeTime()

abstract void java.util.Calendar.computeTime ( )
abstractprotected

Computes

from the Calendar fields.

Exceptions
IllegalArgumentExceptionif the time cannot be computed from the current field values.

◆ equals()

boolean java.util.Calendar.equals ( Object  object)
inline

Compares the specified object to this

and returns whether they are equal. The object must be an instance of

and have the same properties.

Parameters
objectthe object to compare with this object.
Returns
true
if the specified object is equal to this ,
false
otherwise.

◆ get()

int java.util.Calendar.get ( int  field)
inline

Gets the value of the specified field after computing the field values by calling

first.

Parameters
fieldthe field to get.
Returns
the value of the specified field.
Exceptions
IllegalArgumentExceptionif the fields are not set, the time is not set, and the time cannot be computed from the current field values.
ArrayIndexOutOfBoundsExceptionif the field is not inside the range of possible fields. The range is starting at 0 up to .

◆ getActualMaximum()

int java.util.Calendar.getActualMaximum ( int  field)
inline

Gets the maximum value of the specified field for the current date.

Parameters
fieldthe field.
Returns
the maximum value of the specified field.

◆ getActualMinimum()

int java.util.Calendar.getActualMinimum ( int  field)
inline

Gets the minimum value of the specified field for the current date.

Parameters
fieldthe field.
Returns
the minimum value of the specified field.

◆ getAvailableLocales()

static synchronized Locale [] java.util.Calendar.getAvailableLocales ( )
inlinestatic

Returns an array of locales for which custom

instances are available.

Note that Android does not support user-supplied locale service providers.

◆ getFirstDayOfWeek()

int java.util.Calendar.getFirstDayOfWeek ( )
inline

Gets the first day of the week for this

.

Returns
the first day of the week.

◆ getGreatestMinimum()

abstract int java.util.Calendar.getGreatestMinimum ( int  field)
abstract

Gets the greatest minimum value of the specified field. This is the biggest value that

can return for any possible time.

Parameters
fieldthe field.
Returns
the greatest minimum value of the specified field.

◆ getInstance() [1/4]

static synchronized Calendar java.util.Calendar.getInstance ( )
inlinestatic

Constructs a new instance of the

subclass appropriate for the default

Locale

.

Returns
a subclass instance set to the current date and time in the default
Timezone
.

◆ getInstance() [2/4]

static synchronized Calendar java.util.Calendar.getInstance ( Locale  locale)
inlinestatic

Constructs a new instance of the

subclass appropriate for the specified

Locale

.

Parameters
localethe locale to use.
Returns
a subclass instance set to the current date and time.

◆ getInstance() [3/4]

static synchronized Calendar java.util.Calendar.getInstance ( TimeZone  timezone)
inlinestatic

Constructs a new instance of the

subclass appropriate for the default

Locale

, using the specified

TimeZone

.

Parameters
timezonethe
TimeZone
to use.
Returns
a subclass instance set to the current date and time in the specified timezone.

◆ getInstance() [4/4]

static synchronized Calendar java.util.Calendar.getInstance ( TimeZone  timezone,
Locale  locale 
)
inlinestatic

Constructs a new instance of the

subclass appropriate for the specified

Locale

.

Parameters
timezonethe
TimeZone
to use.
localethe
Locale
to use.
Returns
a subclass instance set to the current date and time in the specified timezone.

◆ getLeastMaximum()

abstract int java.util.Calendar.getLeastMaximum ( int  field)
abstract

Gets the smallest maximum value of the specified field. This is the smallest value that

can return for any possible time.

Parameters
fieldthe field number.
Returns
the smallest maximum value of the specified field.

◆ getMaximum()

abstract int java.util.Calendar.getMaximum ( int  field)
abstract

Gets the greatest maximum value of the specified field. This returns the biggest value that

get

can return for the specified field.

Parameters
fieldthe field.
Returns
the greatest maximum value of the specified field.

◆ getMinimalDaysInFirstWeek()

int java.util.Calendar.getMinimalDaysInFirstWeek ( )
inline

Gets the minimal days in the first week of the year.

Returns
the minimal days in the first week of the year.

◆ getMinimum()

abstract int java.util.Calendar.getMinimum ( int  field)
abstract

Gets the smallest minimum value of the specified field. this returns the smallest value thet

get

can return for the specified field.

Parameters
fieldthe field number.
Returns
the smallest minimum value of the specified field.

◆ getTime()

final Date java.util.Calendar.getTime ( )
inline

Gets the time of this

as a

Date

object.

Returns
a new
Date
initialized to the time of this .
Exceptions
IllegalArgumentExceptionif the time is not set and the time cannot be computed from the current field values.

◆ getTimeInMillis()

long java.util.Calendar.getTimeInMillis ( )
inline

Computes the time from the fields if required and returns the time.

Returns
the time of this .
Exceptions
IllegalArgumentExceptionif the time is not set and the time cannot be computed from the current field values.

◆ getTimeZone()

TimeZone java.util.Calendar.getTimeZone ( )
inline

Gets the timezone of this

.

Returns
the
TimeZone
used by this .

◆ hashCode()

int java.util.Calendar.hashCode ( )
inline

Returns an integer hash code for the receiver. Objects which are equal return the same value for this method.

Returns
the receiver's hash.
See also
equals

◆ internalGet()

final int java.util.Calendar.internalGet ( int  field)
inlineprotected

Gets the value of the specified field without recomputing.

Parameters
fieldthe field.
Returns
the value of the specified field.

◆ isLenient()

boolean java.util.Calendar.isLenient ( )
inline

Returns if this

accepts field values which are outside the valid range for the field.

Returns
true
if this is lenient,
false
otherwise.

◆ isSet()

final boolean java.util.Calendar.isSet ( int  field)
inline

Returns whether the specified field is set. Note that the interpretation of "is set" is somewhat technical. In particular, it does not mean that the field's value is up to date. If you want to know whether a field contains an up-to-date value, you must also check

, making this method somewhat useless unless you're a subclass, in which case you can access the

array directly.

A field remains "set" from the first time its value is computed until it's cleared by one of the

methods. Thus "set" does not mean "valid". You probably want to call

get

– which will update fields as necessary – rather than try to make use of this method.

Parameters
fielda field number.
Returns
true
if the specified field is set,
false
otherwise.

◆ roll() [1/2]

void java.util.Calendar.roll ( int  field,
int  value 
)
inline

Adds the specified amount to the specified field and wraps the value of the field when it goes beyond the maximum or minimum value for the current date. Other fields will be adjusted as required to maintain a consistent date.

Parameters
fieldthe field to roll.
valuethe amount to add.

◆ roll() [2/2]

abstract void java.util.Calendar.roll ( int  field,
boolean  increment 
)
abstract

Increment or decrement the specified field and wrap the value of the field when it goes beyond the maximum or minimum value for the current date. Other fields will be adjusted as required to maintain a consistent date.

Parameters
fieldthe number indicating the field to roll.
increment
true
to increment the field,
false
to decrement.

◆ set() [1/4]

void java.util.Calendar.set ( int  field,
int  value 
)
inline

Sets a field to the specified value.

Parameters
fieldthe code indicating the field to modify.
valuethe value.

◆ set() [2/4]

final void java.util.Calendar.set ( int  year,
int  month,
int  day 
)
inline

Sets the year, month and day of the month fields. Other fields are not changed.

Parameters
yearthe year.
monththe month.
daythe day of the month.

◆ set() [3/4]

final void java.util.Calendar.set ( int  year,
int  month,
int  day,
int  hourOfDay,
int  minute 
)
inline

Sets the year, month, day of the month, hour of day and minute fields. Other fields are not changed.

Parameters
yearthe year.
monththe month.
daythe day of the month.
hourOfDaythe hour of day.
minutethe minute.

◆ set() [4/4]

final void java.util.Calendar.set ( int  year,
int  month,
int  day,
int  hourOfDay,
int  minute,
int  second 
)
inline

Sets the year, month, day of the month, hour of day, minute and second fields. Other fields are not changed.

Parameters
yearthe year.
monththe month.
daythe day of the month.
hourOfDaythe hour of day.
minutethe minute.
secondthe second.

◆ setFirstDayOfWeek()

void java.util.Calendar.setFirstDayOfWeek ( int  value)
inline

Sets the first day of the week for this

.

Parameters
valuea day of the week.

◆ setLenient()

void java.util.Calendar.setLenient ( boolean  value)
inline

Sets this

to accept field values which are outside the valid range for the field.

Parameters
valuea boolean value.

◆ setMinimalDaysInFirstWeek()

void java.util.Calendar.setMinimalDaysInFirstWeek ( int  value)
inline

Sets the minimal days in the first week of the year.

Parameters
valuethe minimal days in the first week of the year.

◆ setTime()

final void java.util.Calendar.setTime ( Date  date)
inline

Sets the time of this

.

Parameters
datea
Date
object.

◆ setTimeInMillis()

void java.util.Calendar.setTimeInMillis ( long  milliseconds)
inline

Sets the time of this

.

Parameters
millisecondsthe time as the number of milliseconds since Jan. 1, 1970.

◆ setTimeZone()

void java.util.Calendar.setTimeZone ( TimeZone  timezone)
inline

Sets the

TimeZone

used by this Calendar.

Parameters
timezonea
TimeZone
.

◆ toString()

String java.util.Calendar.toString ( )
inline

Returns the string representation of this

.

Member Data Documentation

◆ ALL_STYLES

final int java.util.Calendar.ALL_STYLES = 0
static

Requests both

and

styles in the map returned by getDisplayNames.

Since
1.6

◆ AM

final int java.util.Calendar.AM = 0
static

Value of the

field indicating the period of the day from midnight to just before noon.

◆ AM_PM

final int java.util.Calendar.AM_PM = 9
static

Field number for

get

and

set

indicating whether the

is before or after noon. E.g., at 10:04:15.250 PM the

is

.

See also
AM
PM
HOUR

◆ APRIL

final int java.util.Calendar.APRIL = 3
static

Value of the

field indicating the fourth month of the year.

◆ areFieldsSet

boolean java.util.Calendar.areFieldsSet
protected

True iff the values in

correspond to

. Despite the name, this is effectively "are the values in fields[] up-to-date?" —

may contain non-zero values and

may contain

true

values even when

is false. Accessing the fields via

get

will ensure the fields are up-to-date.

◆ AUGUST

final int java.util.Calendar.AUGUST = 7
static

Value of the

field indicating the eighth month of the year.

◆ DATE

final int java.util.Calendar.DATE = 5
static

Field number for

get

and

set

indicating the day of the month. This is a synonym for

. The first day of the month has value 1.

See also
DAY_OF_MONTH

◆ DAY_OF_MONTH

final int java.util.Calendar.DAY_OF_MONTH = 5
static

Field number for

get

and

set

indicating the day of the month. This is a synonym for

. The first day of the month has value 1.

See also
DATE

◆ DAY_OF_WEEK

final int java.util.Calendar.DAY_OF_WEEK = 7
static

Field number for

get

and

set

indicating the day of the week. This field takes values

,

,

,

,

,

, and

.

See also
SUNDAY
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY

◆ DAY_OF_WEEK_IN_MONTH

final int java.util.Calendar.DAY_OF_WEEK_IN_MONTH = 8
static

Field number for

get

and

set

indicating the ordinal number of the day of the week within the current month. Together with the

field, this uniquely specifies a day within a month. Unlike

and

, this field's value does not depend on

or

.

through

7

always correspond to DAY_OF_WEEK_IN_MONTH 1;

8

through

15

correspond to

, and so on.

indicates the week before

. Negative values count back from the end of the month, so the last Sunday of a month is specified as

. Because negative values count backward they will usually be aligned differently within the month than positive values. For example, if a month has 31 days,

DAY_OF_WEEK_IN_MONTH -1

will overlap

DAY_OF_WEEK_IN_MONTH 5

and the end of

4

.

See also
DAY_OF_WEEK
WEEK_OF_MONTH

◆ DAY_OF_YEAR

final int java.util.Calendar.DAY_OF_YEAR = 6
static

Field number for

get

and

set

indicating the day number within the current year. The first day of the year has value 1.

◆ DECEMBER

final int java.util.Calendar.DECEMBER = 11
static

Value of the

field indicating the twelfth month of the year.

◆ DST_OFFSET

final int java.util.Calendar.DST_OFFSET = 16
static

Field number for

get

and

set

indicating the daylight savings offset in milliseconds.

◆ ERA

final int java.util.Calendar.ERA = 0
static

Field number for

get

and

set

indicating the era, e.g., AD or BC in the Julian calendar. This is a calendar-specific value; see subclass documentation.

See also
GregorianCalendar::AD
GregorianCalendar::BC

◆ FEBRUARY

final int java.util.Calendar.FEBRUARY = 1
static

Value of the

field indicating the second month of the year.

◆ FIELD_COUNT

final int java.util.Calendar.FIELD_COUNT = 17
static

This is the total number of fields in this calendar.

◆ fields

int [] java.util.Calendar.fields
protected

Contains broken-down field values for the current value of

if

is true, or stale data corresponding to some previous value otherwise. Accessing the fields via

get

will ensure the fields are up-to-date. The array length is always

.

◆ FRIDAY

final int java.util.Calendar.FRIDAY = 6
static

Value of the

field indicating Friday.

◆ HOUR

final int java.util.Calendar.HOUR = 10
static

Field number for

get

and

set

indicating the hour of the morning or afternoon.

is used for the 12-hour clock. E.g., at 10:04:15.250 PM the

is 10.

See also
AM_PM
HOUR_OF_DAY

◆ HOUR_OF_DAY

final int java.util.Calendar.HOUR_OF_DAY = 11
static

Field number for

get

and

set

indicating the hour of the day.

is used for the 24-hour clock. E.g., at 10:04:15.250 PM the

is 22.

See also
HOUR

◆ isSet

boolean [] java.util.Calendar.isSet
protected

Whether the corresponding element in

field[]

has been set. Initially, these are all false. The first time the fields are computed, these are set to true and remain set even if the data becomes stale: you must check

if you want to know whether the value is up-to-date. Note that

is not a safe alternative to accessing this array directly, and will likewise return stale data! The array length is always

.

◆ isTimeSet

boolean java.util.Calendar.isTimeSet
protected

Whether

corresponds to the values in

. If false,

is out-of-date with respect to changes

. Accessing the time via

will always return the correct value.

◆ JANUARY

final int java.util.Calendar.JANUARY = 0
static

Value of the

field indicating the first month of the year.

◆ JULY

final int java.util.Calendar.JULY = 6
static

Value of the

field indicating the seventh month of the year.

◆ JUNE

final int java.util.Calendar.JUNE = 5
static

Value of the

field indicating the sixth month of the year.

◆ LONG

final int java.util.Calendar.LONG = 2
static

Requests long names (such as "January") from getDisplayName or getDisplayNames.

Since
1.6

◆ MARCH

final int java.util.Calendar.MARCH = 2
static

Value of the

field indicating the third month of the year.

◆ MAY

final int java.util.Calendar.MAY = 4
static

Value of the

field indicating the fifth month of the year.

◆ MILLISECOND

final int java.util.Calendar.MILLISECOND = 14
static

Field number for

get

and

set

indicating the millisecond within the second. E.g., at 10:04:15.250 PM the

is 250.

◆ MINUTE

final int java.util.Calendar.MINUTE = 12
static

Field number for

get

and

set

indicating the minute within the hour. E.g., at 10:04:15.250 PM the

is 4.

◆ MONDAY

final int java.util.Calendar.MONDAY = 2
static

Value of the

field indicating Monday.

◆ MONTH

final int java.util.Calendar.MONTH = 2
static

Field number for

get

and

set

indicating the month. This is a calendar-specific value. The first month of the year is

; the last depends on the number of months in a year.

See also
JANUARY
FEBRUARY
MARCH
APRIL
MAY
JUNE
JULY
AUGUST
SEPTEMBER
OCTOBER
NOVEMBER
DECEMBER
UNDECIMBER

◆ NOVEMBER

final int java.util.Calendar.NOVEMBER = 10
static

Value of the

field indicating the eleventh month of the year.

◆ OCTOBER

final int java.util.Calendar.OCTOBER = 9
static

Value of the

field indicating the tenth month of the year.

◆ PM

final int java.util.Calendar.PM = 1
static

Value of the

field indicating the period of the day from noon to just before midnight.

◆ SATURDAY

final int java.util.Calendar.SATURDAY = 7
static

Value of the

field indicating Saturday.

◆ SECOND

final int java.util.Calendar.SECOND = 13
static

Field number for

get

and

set

indicating the second within the minute. E.g., at 10:04:15.250 PM the

is 15.

◆ SEPTEMBER

final int java.util.Calendar.SEPTEMBER = 8
static

Value of the

field indicating the ninth month of the year.

◆ SHORT

final int java.util.Calendar.SHORT = 1
static

Requests short names (such as "Jan") from getDisplayName or getDisplayNames.

Since
1.6

◆ SUNDAY

final int java.util.Calendar.SUNDAY = 1
static

Value of the

field indicating Sunday.

◆ THURSDAY

final int java.util.Calendar.THURSDAY = 5
static

Value of the

field indicating Thursday.

◆ time

long java.util.Calendar.time
protected

A time in milliseconds since January 1, 1970. See

. Accessing the time via

will always return the correct value.

◆ TUESDAY

final int java.util.Calendar.TUESDAY = 3
static

Value of the

field indicating Tuesday.

◆ UNDECIMBER

final int java.util.Calendar.UNDECIMBER = 12
static

Value of the

field indicating the thirteenth month of the year. Although

GregorianCalendar

does not use this value, lunar calendars do.

◆ WEDNESDAY

final int java.util.Calendar.WEDNESDAY = 4
static

Value of the

field indicating Wednesday.

◆ WEEK_OF_MONTH

final int java.util.Calendar.WEEK_OF_MONTH = 4
static

Field number for

get

and

set

indicating the week number within the current month. The first week of the month, as defined by

and

, has value 1. Subclasses define the value of

for days before the first week of the month.

See also
getFirstDayOfWeek
getMinimalDaysInFirstWeek

◆ WEEK_OF_YEAR

final int java.util.Calendar.WEEK_OF_YEAR = 3
static

Field number for

get

and

set

indicating the week number within the current year. The first week of the year, as defined by

and

, has value 1. Subclasses define the value of

for days before the first week of the year.

See also
getFirstDayOfWeek
getMinimalDaysInFirstWeek

◆ YEAR

final int java.util.Calendar.YEAR = 1
static

Field number for

get

and

set

indicating the year. This is a calendar-specific value; see subclass documentation.

◆ ZONE_OFFSET

final int java.util.Calendar.ZONE_OFFSET = 15
static

Field number for

get

and

set

indicating the raw offset from GMT in milliseconds.


The documentation for this class was generated from the following file: