| java.lang.Object | |
| ↳ | java.util.Calendar |
Known Direct Subclasses
|
Calendar is an abstract class which provides the conversion between Dates and integer calendar fields, such as the month, year or minute. Subclasses of this class implement a specific calendar type, such as the gregorian calendar.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | AM | ||||||||||
| int | AM_PM | ||||||||||
| int | APRIL | ||||||||||
| int | AUGUST | ||||||||||
| int | DATE | ||||||||||
| int | DAY_OF_MONTH | ||||||||||
| int | DAY_OF_WEEK | ||||||||||
| int | DAY_OF_WEEK_IN_MONTH | ||||||||||
| int | DAY_OF_YEAR | ||||||||||
| int | DECEMBER | ||||||||||
| int | DST_OFFSET | ||||||||||
| int | ERA | ||||||||||
| int | FEBRUARY | ||||||||||
| int | FIELD_COUNT | ||||||||||
| int | FRIDAY | ||||||||||
| int | HOUR | ||||||||||
| int | HOUR_OF_DAY | ||||||||||
| int | JANUARY | ||||||||||
| int | JULY | ||||||||||
| int | JUNE | ||||||||||
| int | MARCH | ||||||||||
| int | MAY | ||||||||||
| int | MILLISECOND | ||||||||||
| int | MINUTE | ||||||||||
| int | MONDAY | ||||||||||
| int | MONTH | ||||||||||
| int | NOVEMBER | ||||||||||
| int | OCTOBER | ||||||||||
| int | PM | ||||||||||
| int | SATURDAY | ||||||||||
| int | SECOND | ||||||||||
| int | SEPTEMBER | ||||||||||
| int | SUNDAY | ||||||||||
| int | THURSDAY | ||||||||||
| int | TUESDAY | ||||||||||
| int | UNDECIMBER | ||||||||||
| int | WEDNESDAY | ||||||||||
| int | WEEK_OF_MONTH | ||||||||||
| int | WEEK_OF_YEAR | ||||||||||
| int | YEAR | ||||||||||
| int | ZONE_OFFSET | ||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| areFieldsSet | Set to true when the calendar fields have been set from the time, set to false when a field is changed and the fields must be recomputed. | ||||||||||
| fields | An integer array of calendar fields. | ||||||||||
| isSet | |||||||||||
| isTimeSet | Set to true when the time has been set, set to false when a field is changed and the time must be recomputed. | ||||||||||
| time | The time in milliseconds since January 1, 1970. | ||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Initializes this Calendar instance using the default TimeZone and Locale.
| |||||||||||
Initializes this Calendar instance using the specified TimeZone and
Locale.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified amount to a Calendar field.
| |||||||||||
Returns if the Date specified by this Calendar instance is after the Date
specified by the parameter.
| |||||||||||
Returns if the Date specified by this Calendar instance is before the
Date specified by the parameter.
| |||||||||||
Clears all of the fields of this Calendar.
| |||||||||||
Clears the specified field to zero.
| |||||||||||
Returns a new Calendar with the same properties.
| |||||||||||
Compares the times of the two Calendars, which represent the milliseconds
from the January 1, 1970 00:00:00.000 GMT (Gregorian).
| |||||||||||
Compares the specified object to this Calendar and answer if they are
equal.
| |||||||||||
Gets the value of the specified field after computing the field values
from the time if required.
| |||||||||||
Gets the maximum value of the specified field for the current date.
| |||||||||||
Gets the minimum value of the specified field for the current date.
| |||||||||||
Gets the list of installed Locales which support Calendar.
| |||||||||||
Gets the first day of the week for this Calendar.
| |||||||||||
Gets the greatest minimum value of the specified field.
| |||||||||||
Constructs a new instance of the Calendar subclass appropriate for the
specified Locale.
| |||||||||||
Constructs a new instance of the Calendar subclass appropriate for the
default Locale.
| |||||||||||
Constructs a new instance of the Calendar subclass appropriate for the
default Locale, using the specified TimeZone.
| |||||||||||
Constructs a new instance of the Calendar subclass appropriate for the
specified Locale.
| |||||||||||
Gets the smallest maximum value of the specified field.
| |||||||||||
Gets the greatest maximum value of the specified field.
| |||||||||||
Gets the minimal days in the first week of the year.
| |||||||||||
Gets the smallest minimum value of the specified field.
| |||||||||||
Gets the time of this Calendar as a Date object.
| |||||||||||
Computes the time from the fields if required and returns the time.
| |||||||||||
Gets the timezone of this Calendar.
| |||||||||||
Returns an integer hash code for the receiver.
| |||||||||||
Returns if this Calendar accepts field values which are outside the valid
range for the field.
| |||||||||||
Returns if the specified field is set.
| |||||||||||
Adds the specified amount the specified field and wrap the value of the
field when it goes beyond the maximum or minimum value for the current
date.
| |||||||||||
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.
| |||||||||||
Sets the year, month, day of the month, hour of day and minute fields.
| |||||||||||
Sets a field to the specified value.
| |||||||||||
Sets the year, month and day of the month fields.
| |||||||||||
Sets the year, month, day of the month, hour of day, minute and second
fields.
| |||||||||||
Sets the first day of the week for this Calendar.
| |||||||||||
Sets this Calendar to accept field values which are outside the valid
range for the field.
| |||||||||||
Sets the minimal days in the first week of the year.
| |||||||||||
Sets the time of this Calendar.
| |||||||||||
Sets the time of this Calendar.
| |||||||||||
Sets the timezone used by this Calendar.
| |||||||||||
Returns the string representation of this Calendar.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Computes the time from the fields if the time has not already been set.
| |||||||||||
Computes the Calendar fields from the time.
| |||||||||||
Computes the time from the Calendar fields.
| |||||||||||
Gets the value of the specified field without recomputing.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface java.lang.Comparable
| |||||||||||
Set to true when the calendar fields have been set from the time, set to false when a field is changed and the fields must be recomputed.
An integer array of calendar fields.
Set to true when the time has been set, set to false when a field is changed and the time must be recomputed.
The time in milliseconds since January 1, 1970.
Initializes this Calendar instance using the default TimeZone and Locale.
Initializes this Calendar instance using the specified TimeZone and Locale.
| timezone | the timezone |
|---|---|
| locale | the locale |
Adds the specified amount to a Calendar field.
| field | the Calendar field to modify |
|---|---|
| value | the amount to add to the field |
| IllegalArgumentException | when the specified field is DST_OFFSET or ZONE_OFFSET. |
|---|
Returns if the Date specified by this Calendar instance is after the Date specified by the parameter. The comparison is not dependent on the time zones of the Calendars.
| calendar | the Calendar instance to compare |
|---|
| IllegalArgumentException | when the time is not set and the time cannot be computed from the current field values |
|---|
Returns if the Date specified by this Calendar instance is before the Date specified by the parameter. The comparison is not dependent on the time zones of the Calendars.
| calendar | the Calendar instance to compare |
|---|
| IllegalArgumentException | when the time is not set and the time cannot be computed from the current field values |
|---|
Clears all of the fields of this Calendar. All fields are initialized to zero.
Clears the specified field to zero.
| field | the field to clear |
|---|
Returns a new Calendar with the same properties.
Compares the times of the two Calendars, which represent the milliseconds from the January 1, 1970 00:00:00.000 GMT (Gregorian).
| anotherCalendar | another calendar that is compared with. |
|---|
| NullPointerException | if the argument of calendar is null. |
|---|---|
| IllegalArgumentException | if the argument of the calendar does not include a valid time value. |
Compares the specified object to this Calendar and answer if they are equal. The object must be an instance of Calendar and have the same properties.
| object | the object to compare with this object |
|---|
Gets the value of the specified field after computing the field values from the time if required.
| field | the field |
|---|
| IllegalArgumentException | when the fields are not set, the time is not set, and the time cannot be computed from the current field values |
|---|
Gets the maximum value of the specified field for the current date.
| field | the field |
|---|
Gets the minimum value of the specified field for the current date.
| field | the field |
|---|
Gets the list of installed Locales which support Calendar.
Gets the first day of the week for this Calendar.
Gets the greatest minimum value of the specified field.
| field | the field |
|---|
Constructs a new instance of the Calendar subclass appropriate for the specified Locale.
| timezone | the timezone to use |
|---|---|
| locale | the locale to use |
Constructs a new instance of the Calendar subclass appropriate for the default Locale.
Constructs a new instance of the Calendar subclass appropriate for the default Locale, using the specified TimeZone.
| timezone | the timezone to use |
|---|
Constructs a new instance of the Calendar subclass appropriate for the specified Locale.
| locale | the locale to use |
|---|
Gets the smallest maximum value of the specified field.
| field | the field |
|---|
Gets the greatest maximum value of the specified field.
| field | the field |
|---|
Gets the minimal days in the first week of the year.
Gets the smallest minimum value of the specified field.
| field | the field |
|---|
Gets the time of this Calendar as a Date object.
| IllegalArgumentException | when the time is not set and the time cannot be computed from the current field values |
|---|
Computes the time from the fields if required and returns the time.
| IllegalArgumentException | when the time is not set and the time cannot be computed from the current field values |
|---|
Gets the timezone of this Calendar.
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.
Returns if this Calendar accepts field values which are outside the valid range for the field.
Returns if the specified field is set.
| field | a calendar field |
|---|
Adds the specified amount 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.
| field | the field to roll |
|---|---|
| value | the amount to add |
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.
| field | the field to roll |
|---|---|
| increment | true to increment the field, false to decrement |
Sets the year, month, day of the month, hour of day and minute fields.
| year | the year |
|---|---|
| month | the month |
| day | the day of the month |
| hourOfDay | the hour of day |
| minute | the minute |
Sets a field to the specified value.
| field | the Calendar field to modify |
|---|---|
| value | the value |
Sets the year, month and day of the month fields.
| year | the year |
|---|---|
| month | the month |
| day | the day of the month |
Sets the year, month, day of the month, hour of day, minute and second fields.
| year | the year |
|---|---|
| month | the month |
| day | the day of the month |
| hourOfDay | the hour of day |
| minute | the minute |
| second | the second |
Sets the first day of the week for this Calendar.
| value | a Calendar day of the week |
|---|
Sets this Calendar to accept field values which are outside the valid range for the field.
| value | a boolean value |
|---|
Sets the minimal days in the first week of the year.
| value | the minimal days in the first week of the year |
|---|
Sets the time of this Calendar.
| date | a Date object |
|---|
Sets the time of this Calendar.
| milliseconds | the time as the number of milliseconds since Jan. 1, 1970 |
|---|
Sets the timezone used by this Calendar.
| timezone | a TimeZone |
|---|
Returns the string representation of this Calendar.
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.
| IllegalArgumentException | when the time is not set and the time cannot be computed from the current field values |
|---|
Computes the Calendar fields from the time.
Computes the time from the Calendar fields.
| IllegalArgumentException | when the time cannot be computed from the current field values |
|---|
Gets the value of the specified field without recomputing.
| field | the field |
|---|