    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class java.util.Calendar

    java.lang.Object
       |
       +----java.util.Calendar

public abstract class Calendar
extends Object
implements Serializable, Cloneable

`Calendar` is an abstract base class for converting between a `Date` object and a set of integer fields such as `YEAR`, `MONTH`, `DAY`, `HOUR`, and so on. (A `Date` object represents a specific instant in time with millisecond precision. See `java.util.Date` for information about the `Date` class.)

Subclasses of `Calendar` interpret a `Date` according to the rules of a specific calendar system. The JDK provides one concrete subclass of `Calendar`: `GregorianCalendar`. Future subclasses could represent the various types of lunar calendars in use in many parts of the world.

Like other locale-sensitive classes, `Calendar` provides a class method, `getInstance`, for getting a generally useful object of this type. `Calendar`'s `getInstance` method returns a `GregorianCalendar` object whose time fields have been initialized with the current date and time:

>      Calendar rightNow = Calendar.getInstance();

A `Calendar` 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).

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: for some non-Gregorian calendars, different fields may be necessary for complete disambiguation. For example, a full specification of the historial Arabic astronomical calendar requires year, month, day-of-month and day-of-week in some cases.

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
2. Although historically not precise, midnight also belongs to "am", and noon belongs to "pm", so on the same day, 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

`Calendar` 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()`, `getTime()`, or `getTimeInMillis()` 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 `getTime()`is then called. However, a call to `set(Calendar.DAY_OF_MONTH, 30)` before the call to `getTime()` 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. `HOUR` is a smaller field than `DAY_OF_MONTH`. 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 `MONTH` field to September, since adding 13 months to August gives September of the next year. Since `DAY_OF_MONTH` cannot be 31 in September in a `GregorianCalendar`, add rule 2 sets the `DAY_OF_MONTH` to 30, the closest possible value. Although it is a smaller field, `DAY_OF_WEEK` is not adjusted by rule 2, since it is expected to change when the month changes in a `GregorianCalendar`.

`roll(f, up/down)` adds `+1/-1` to field `f` without changing larger fields. This is equivalent to calling `add(f, +1/-1)` with the following adjustment:

> Roll rule. Larger fields are unchanged after the call. A larger field represents a larger unit of time. `DAY_OF_MONTH` is a larger field than `HOUR`.

Example: Consider a `GregorianCalendar` originally set to October 31, 1999. Calling `roll(Calendar.MONTH, true)` sets the calendar to Novermber 30, 1999. Add rule 1 sets the `MONTH` field to November. Using a `GregorianCalendar`, the `DAY_OF_MONTH` cannot be 31 in the month November. Add rule 2 sets it to the closest possible value, 30. Calling `roll(Calendar.MONTH, true)` two more times sets the calendar further to Jaunary 30, 1999. When rolling from December to January, the roll rule maintains the `YEAR` field value of 1999.

Example: Consider a `GregorianCalendar` originally set to Sunday June 6, 1999. Calling `roll(Calendar.WEEK_OF_MONTH, false)` 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 `MONTH` must not change when the `WEEK_OF_MONTH` 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 `DAY_OF_WEEK`, an invariant when changing the `WEEK_OF_MONTH`, 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. If the underlying implementation uses `add(Calendar.MONTH, 1)`, it will read 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 `add(Calendar.MONTH, 2)`, after the user presses the month increment button twice, it will read March 31, 1999 as most users will intuitively expect. In contrast, since `roll()` can only go up or down by one, calling `roll(Calendar.MONTH, true)` twice will result in March 28, 1999. In addition, `roll()` does not change the `YEAR` field.

See Also:
  Date, GregorianCalendar, TimeZone, DateFormat

##

AM
  Useful constant for hour in 12-hour clock.
AM_PM
  Useful constant for date and time.
APRIL
  Useful constant for month.
areFieldsSet
  True if the fields are in sync with the currently set time of this Calendar.
AUGUST
  Useful constant for month.
DATE
  Useful constant for date and time.
DAY_OF_MONTH
  Useful constant for date and time.
DAY_OF_WEEK
  Useful constant for date and time.
DAY_OF_WEEK_IN_MONTH
  Useful constant for date and time.
DAY_OF_YEAR
  Useful constant for date and time.
DECEMBER
  Useful constant for month.
DST_OFFSET
  Useful constant for date and time.
ERA
  Useful constant for date and time.
FEBRUARY
  Useful constant for month.
FIELD_COUNT
  Useful constant for date and time.
fields
  The time fields containing values into which the millis is computed.
FRIDAY
  Useful constant for days of week.
HOUR
  Useful constant for date and time.
HOUR_OF_DAY
  Useful constant for date and time.
isSet
  The flags which tell if a specified time field for the calendar is set.
isTimeSet
  The flag which indicates if the current time is set for the calendar.
JANUARY
  Useful constant for month.
JULY
  Useful constant for month.
JUNE
  Useful constant for month.
MARCH
  Useful constant for month.
MAY
  Useful constant for month.
MILLISECOND
  Useful constant for date and time.
MINUTE
  Useful constant for date and time.
MONDAY
  Useful constant for days of week.
MONTH
  Useful constant for date and time.
NOVEMBER
  Useful constant for month.
OCTOBER
  Useful constant for month.
PM
  Useful constant for hour in 12-hour clock.
SATURDAY
  Useful constant for days of week.
SECOND
  Useful constant for date and time.
SEPTEMBER
  Useful constant for month.
SUNDAY
  Useful constant for days of week.
THURSDAY
  Useful constant for days of week.
time
  The current time set for the calendar.
TUESDAY
  Useful constant for days of week.
UNDECIMBER
  Useful constant for month.
WEDNESDAY
  Useful constant for days of week.
WEEK_OF_MONTH
  Useful constant for date and time.
WEEK_OF_YEAR
  Useful constant for date and time.
YEAR
  Useful constant for date and time.
ZONE_OFFSET
  Useful constant for date and time.

##

Calendar()
  Constructs a Calendar with the default time zone as returned by TimeZone.getDefault(), and the default locale.
Calendar(TimeZone, Locale)
  Constructs a Calendar with the given time zone and locale.

##

add(int, int)
  Date Arithmetic function.
after(Object)
  Compares the time field records.
before(Object)
  Compares the time field records.
clear()
  Clears the values of all the time fields.
clear(int)
  Clears the value in the given time field.
clone()
  Overrides Cloneable
complete()
  Fills in any unset fields in the time field list.
computeFields()
  Converts UTC as milliseconds to time field values.
computeTime()
  Converts Calendar's time field values to UTC as milliseconds.
equals(Object)
  Compares this calendar to the specified object.
get(int)
  Gets the value for a given time field.
getAvailableLocales()
  Gets the set of locales for which Calendars are installed.
getFirstDayOfWeek()
  Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
getGreatestMinimum(int)
  Gets the highest minimum value for the given field if varies.
getInstance()
  Gets a Calendar using the default timezone and locale.
getInstance(Locale)
  Gets a Calendar using the default timezone and given locale.
getInstance(TimeZone)
  Gets a Calendar using the given timezone and default locale.
getInstance(TimeZone, Locale)
  Gets a Calendar using the given timezone and given locale.
getLeastMaximum(int)
  Gets the lowest maximum value for the given field if varies.
getMaximum(int)
  Gets the maximum value for the given time field.
getMinimalDaysInFirstWeek()
  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, getMinimalDaysInFirstWeek returns 1.
getMinimum(int)
  Gets the minimum value for the given time field.
getTime()
  Gets this Calendar's current time.
getTimeInMillis()
  Gets this Calendar's current time as a long.
getTimeZone()
  Gets the time zone.
internalGet(int)
  Gets the value for a given time field.
isLenient()
  Tell whether date/time interpretation is to be lenient.
isSet(int)
  Determines if the given time field has a value set.
roll(int, boolean)
  Time Field Rolling function.
set(int, int)
  Sets the time field with the given value.
set(int, int, int)
  Sets the values for the fields year, month, and date.
set(int, int, int, int, int)
  Sets the values for the fields year, month, date, hour, and minute.
set(int, int, int, int, int, int)
  Sets the values for the fields year, month, date, hour, minute, and second.
setFirstDayOfWeek(int)
  Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
setLenient(boolean)
  Specify whether or not date/time interpretation is to be lenient.
setMinimalDaysInFirstWeek(int)
  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 the method with value 1.
setTime(Date)
  Sets this Calendar's current time with the given Date.
setTimeInMillis(long)
  Sets this Calendar's current time from the given long value.
setTimeZone(TimeZone)
  Sets the time zone with the given time zone value.
toString()
  Return a string representation of this calendar.

##

ERA

     public static final int ERA

  Useful constant for date and time. Used in time fields. ERA is calendar specific.

YEAR

     public static final int YEAR

  Useful constant for date and time. Used in time fields.

MONTH

     public static final int MONTH

  Useful constant for date and time. Used in time fields.

WEEK_OF_YEAR

     public static final int WEEK_OF_YEAR

  Useful constant for date and time. Used in time fields.

WEEK_OF_MONTH

     public static final int WEEK_OF_MONTH

  Useful constant for date and time. Used in time fields.

DATE

     public static final int DATE

  Useful constant for date and time. Used in time fields. This is a synonym for DAY_OF_MONTH.

DAY_OF_MONTH

     public static final int DAY_OF_MONTH

  Useful constant for date and time. Used in time fields. This is a synonym for DATE.

DAY_OF_YEAR

     public static final int DAY_OF_YEAR

  Useful constant for date and time. Used in time fields.

DAY_OF_WEEK

     public static final int DAY_OF_WEEK

  Useful constant for date and time. Used in time fields.

DAY_OF_WEEK_IN_MONTH

     public static final int DAY_OF_WEEK_IN_MONTH

  Useful constant for date and time. Used in time fields.

AM_PM

     public static final int AM_PM

  Useful constant for date and time. Used in time fields.

HOUR

     public static final int HOUR

  Useful constant for date and time. Used in time fields. HOUR is used for the 12-hour clock.

HOUR_OF_DAY

     public static final int HOUR_OF_DAY

  Useful constant for date and time. Used in time fields. HOUR_OF_DAY is used for the 24-hour clock.

MINUTE

     public static final int MINUTE

  Useful constant for date and time. Used in time fields.

SECOND

     public static final int SECOND

  Useful constant for date and time. Used in time fields.

MILLISECOND

     public static final int MILLISECOND

  Useful constant for date and time. Used in time fields.

ZONE_OFFSET

     public static final int ZONE_OFFSET

  Useful constant for date and time. Used in time fields.

DST_OFFSET

     public static final int DST_OFFSET

  Useful constant for date and time. Used in time fields.

FIELD_COUNT

     public static final int FIELD_COUNT

  Useful constant for date and time. FIELD_COUNT is used for the time field array creation.

SUNDAY

     public static final int SUNDAY

  Useful constant for days of week. Used in GregorianCalendar.

MONDAY

     public static final int MONDAY

  Useful constant for days of week. Used in GregorianCalendar.

TUESDAY

     public static final int TUESDAY

  Useful constant for days of week. Used in GregorianCalendar.

WEDNESDAY

     public static final int WEDNESDAY

  Useful constant for days of week. Used in GregorianCalendar.

THURSDAY

     public static final int THURSDAY

  Useful constant for days of week. Used in GregorianCalendar.

FRIDAY

     public static final int FRIDAY

  Useful constant for days of week. Used in GregorianCalendar.

SATURDAY

     public static final int SATURDAY

  Useful constant for days of week. Used in GregorianCalendar.

JANUARY

     public static final int JANUARY

  Useful constant for month. Used in GregorianCalendar. Note: Calendar month is now 0-based.

FEBRUARY

     public static final int FEBRUARY

  Useful constant for month. Used in GregorianCalendar.

MARCH

     public static final int MARCH

  Useful constant for month. Used in GregorianCalendar.

APRIL

     public static final int APRIL

  Useful constant for month. Used in GregorianCalendar.

MAY

     public static final int MAY

  Useful constant for month. Used in GregorianCalendar.

JUNE

     public static final int JUNE

  Useful constant for month. Used in GregorianCalendar.

JULY

     public static final int JULY

  Useful constant for month. Used in GregorianCalendar.

AUGUST

     public static final int AUGUST

  Useful constant for month. Used in GregorianCalendar.

SEPTEMBER

     public static final int SEPTEMBER

  Useful constant for month. Used in GregorianCalendar.

OCTOBER

     public static final int OCTOBER

  Useful constant for month. Used in GregorianCalendar.

NOVEMBER

     public static final int NOVEMBER

  Useful constant for month. Used in GregorianCalendar.

DECEMBER

     public static final int DECEMBER

  Useful constant for month. Used in GregorianCalendar.

UNDECIMBER

     public static final int UNDECIMBER

  Useful constant for month. Used in GregorianCalendar. UNDECIMBER is an artifical name. This 13th month is for lunar calendars.

AM

     public static final int AM

  Useful constant for hour in 12-hour clock. Used in GregorianCalendar.

PM

     public static final int PM

  Useful constant for hour in 12-hour clock. Used in GregorianCalendar.

fields

     protected int fields[]

  The time fields containing values into which the millis is computed.

isSet

     protected boolean isSet[]

  The flags which tell if a specified time field for the calendar is set. A new object has no fields set. After the first call to a method which generates the fields, they all remain set after that.

time

     protected long time

  The current time set for the calendar.

isTimeSet

     protected boolean isTimeSet

  The flag which indicates if the current time is set for the calendar. The time is made invalid by the user setting an individual field.

areFieldsSet

     protected boolean areFieldsSet

  True if the fields are in sync with the currently set time of this Calendar. If false, then the next attempt to get the value of a field will force a recomputation of all fields from the current value of the time field. This should really be named areFieldsInSync, but the old name is retained for backward compatibility.

##

Calendar

     protected Calendar()

  Constructs a Calendar with the default time zone as returned by TimeZone.getDefault(), and the default locale.

  See Also:
    getDefault

Calendar

     protected Calendar(TimeZone zone,
                        Locale aLocale)

  Constructs a Calendar with the given time zone and locale.

  Parameters:
    zone - the given time zone.

##

getInstance

     public static synchronized Calendar getInstance()

  Gets a Calendar using the default timezone and locale.

  Returns:
    a Calendar.

getInstance

     public static synchronized Calendar getInstance(TimeZone zone)

  Gets a Calendar using the given timezone and default locale.

  Parameters:
    zone - the given timezone.
  Returns:
    a Calendar.

getInstance

     public static synchronized Calendar getInstance(Locale aLocale)

  Gets a Calendar using the default timezone and given locale.

  Parameters:
    aLocale - the given locale.
  Returns:
    a Calendar.

getInstance

     public static synchronized Calendar getInstance(TimeZone zone,
                                                     Locale aLocale)

  Gets a Calendar using the given timezone and given locale.

  Parameters:
    zone - the given timezone.
    aLocale - the given locale.
  Returns:
    a Calendar.

getAvailableLocales

     public static synchronized Locale[] getAvailableLocales()

  Gets the set of locales for which Calendars are installed.

  Returns:
    the set of locales for which Calendars are installed.

computeTime

     protected abstract void computeTime()

  Converts Calendar's time field values to UTC as milliseconds.

computeFields

     protected abstract void computeFields()

  Converts UTC as milliseconds to time field values. This allows you to sync up the time field values with a new time that is set for the calendar. The time is not recomputed first; to recompute the time, then the fields, call the `complete` method.

  See Also:
    complete

getTime

     public final Date getTime()

  Gets this Calendar's current time.

  Returns:
    the current time.

setTime

     public final void setTime(Date date)

  Sets this Calendar's current time with the given Date.

  Parameters:
    date - the given Date.

getTimeInMillis

     protected long getTimeInMillis()

  Gets this Calendar's current time as a long.

  Returns:
    the current time as UTC milliseconds from the epoch.

setTimeInMillis

     protected void setTimeInMillis(long millis)

  Sets this Calendar's current time from the given long value.

  Parameters:
    date - the new time in UTC milliseconds from the epoch.

get

     public final int get(int field)

  Gets the value for a given time field.

  Parameters:
    field - the given time field.
  Returns:
    the value for the given time field.

internalGet

     protected final int internalGet(int field)

  Gets the value for a given time field. This is an internal fast time field value getter for the subclasses.

  Parameters:
    field - the given time field.
  Returns:
    the value for the given time field.

set

     public final void set(int field,
                           int value)

  Sets the time field with the given value.

  Parameters:
    field - the given time field.
    value - the value to be set for the given time field.

set

     public final void set(int year,
                           int month,
                           int date)

  Sets the values for the fields year, month, and date. Previous values of other fields are retained. If this is not desired, call `clear` first.

  Parameters:
    year - the value used to set the YEAR time field.
    month - the value used to set the MONTH time field. Month value is 0-based. e.g., 0 for January.
    date - the value used to set the DATE time field.

set

     public final void set(int year,
                           int month,
                           int date,
                           int hour,
                           int minute)

  Sets the values for the fields year, month, date, hour, and minute. Previous values of other fields are retained. If this is not desired, call `clear` first.

  Parameters:
    year - the value used to set the YEAR time field.
    month - the value used to set the MONTH time field. Month value is 0-based. e.g., 0 for January.
    date - the value used to set the DATE time field.
    hour - the value used to set the HOUR_OF_DAY time field.
    minute - the value used to set the MINUTE time field.

set

     public final void set(int year,
                           int month,
                           int date,
                           int hour,
                           int minute,
                           int second)

  Sets the values for the fields year, month, date, hour, minute, and second. Previous values of other fields are retained. If this is not desired, call `clear` first.

  Parameters:
    year - the value used to set the YEAR time field.
    month - the value used to set the MONTH time field. Month value is 0-based. e.g., 0 for January.
    date - the value used to set the DATE time field.
    hour - the value used to set the HOUR_OF_DAY time field.
    minute - the value used to set the MINUTE time field.
    second - the value used to set the SECOND time field.

clear

     public final void clear()

  Clears the values of all the time fields.

clear

     public final void clear(int field)

  Clears the value in the given time field.

  Parameters:
    field - the time field to be cleared.

isSet

     public final boolean isSet(int field)

  Determines if the given time field has a value set.

  Returns:
    true if the given time field has a value set; false otherwise.

complete

     protected void complete()

  Fills in any unset fields in the time field list.

equals

     public abstract boolean equals(Object obj)

  Compares this calendar to the specified object. The result is `true` if and only if the argument is not `null` and is a `Calendar` object that represents the same calendar as this object.

  Parameters:
    obj - the object to compare with.
  Returns:
    `true` if the objects are the same; `false` otherwise.
  Overrides:
    equals in class Object

before

     public abstract boolean before(Object when)

  Compares the time field records. Equivalent to comparing result of conversion to UTC.

  Parameters:
    when - the Calendar to be compared with this Calendar.
  Returns:
    true if the current time of this Calendar is before the time of Calendar when; false otherwise.

after

     public abstract boolean after(Object when)

  Compares the time field records. Equivalent to comparing result of conversion to UTC.

  Parameters:
    when - the Calendar to be compared with this Calendar.
  Returns:
    true if the current time of this Calendar is after the time of Calendar when; false otherwise.

add

     public abstract void add(int field,
                              int amount)

  Date Arithmetic function. Adds the specified (signed) amount of time to the given time field, based on the calendar's rules. For example, to subtract 5 days from the current time of the calendar, you can achieve it by calling:

  add(Calendar.DATE, -5).

  Parameters:
    field - the time field.
    amount - the amount of date or time to be added to the field.

roll

     public abstract void roll(int field,
                               boolean up)

  Time Field Rolling function. Rolls (up/down) a single unit of time on the given time field. For example, to roll the current date up by one day, you can achieve it by calling:

  roll(Calendar.DATE, true). When rolling on the year or Calendar.YEAR field, it will roll the year value in the range between 1 and the value returned by calling getMaximum(Calendar.YEAR). When rolling on the month or Calendar.MONTH field, other fields like date might conflict and, need to be changed. For instance, rolling the month on the date 01/31/96 will result in 03/02/96. When rolling on the hour-in-day or Calendar.HOUR_OF_DAY field, it will roll the hour value in the range between 0 and 23, which is zero-based.

  Parameters:
    field - the time field.
    up - indicates if the value of the specified time field is to be rolled up or rolled down. Use true if rolling up, false otherwise.

setTimeZone

     public void setTimeZone(TimeZone value)

  Sets the time zone with the given time zone value.

  Parameters:
    value - the given time zone.

getTimeZone

     public TimeZone getTimeZone()

  Gets the time zone.

  Returns:
    the time zone object associated with this calendar.

setLenient

     public void setLenient(boolean lenient)

  Specify whether or not date/time interpretation is to be lenient. With lenient interpretation, a date such as "February 942, 1996" will be treated as being equivalent to the 941st day after February 1, 1996. With strict interpretation, such dates will cause an exception to be thrown.

  See Also:
    setLenient

isLenient

     public boolean isLenient()

  Tell whether date/time interpretation is to be lenient.

setFirstDayOfWeek

     public void setFirstDayOfWeek(int value)

  Sets what the first day of the week is; e.g., Sunday in US, Monday in France.

  Parameters:
    value - the given first day of the week.

getFirstDayOfWeek

     public int getFirstDayOfWeek()

  Gets what the first day of the week is; e.g., Sunday in US, Monday in France.

  Returns:
    the first day of the week.

setMinimalDaysInFirstWeek

     public void setMinimalDaysInFirstWeek(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 the method with value 1. If it must be a full week, use value 7.

  Parameters:
    value - the given minimal days required in the first week of the year.

getMinimalDaysInFirstWeek

     public int getMinimalDaysInFirstWeek()

  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, getMinimalDaysInFirstWeek returns 1. If the minimal days required must be a full week, getMinimalDaysInFirstWeek returns 7.

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

getMinimum

     public abstract int getMinimum(int field)

  Gets the minimum value for the given time field. e.g., for Gregorian DAY_OF_MONTH, 1.

  Parameters:
    field - the given time field.
  Returns:
    the minimum value for the given time field.

getMaximum

     public abstract int getMaximum(int field)

  Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH, 31.

  Parameters:
    field - the given time field.
  Returns:
    the maximum value for the given time field.

getGreatestMinimum

     public abstract int getGreatestMinimum(int field)

  Gets the highest minimum value for the given field if varies. Otherwise same as getMinimum(). For Gregorian, no difference.

  Parameters:
    field - the given time field.
  Returns:
    the highest minimum value for the given time field.

getLeastMaximum

     public abstract int getLeastMaximum(int field)

  Gets the lowest maximum value for the given field if varies. Otherwise same as getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.

  Parameters:
    field - the given time field.
  Returns:
    the lowest maximum value for the given time field.

clone

     public Object clone()

  Overrides Cloneable

  Overrides:
    clone in class Object

toString

     public String toString()

  Return a string representation of this calendar.

  Returns:
    a string representation of this calendar.
  Overrides:
    toString in class Object

    All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.