java.lang.Object | |
↳ | sun.util.calendar.CalendarSystem |
![]() |
![]() |
CalendarSystem
is an abstract class that defines the
programming interface to deal with calendar date and time.
CalendarSystem
instances are singletons. For
example, there exists only one Gregorian calendar instance in the
Java runtime environment. A singleton instance can be obtained
calling one of the static factory methods.
For the methods in a CalendarSystem
that manipulate
a CalendarDate
, CalendarDate
s that have
been created by the CalendarSystem
must be
specified. Otherwise, the methods throw an exception. This is
because, for example, a Chinese calendar date can't be understood
by the Hebrew calendar system.
Name Calendar System --------------------------------------- gregorian Gregorian Calendar julian Julian Calendar japanese Japanese Imperial Calendar
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a
CalendarSystem specified by the calendar
name. | |||||||||||
Calculates calendar fields from the specified number of
milliseconds since the Epoch, January 1, 1970 00:00:00 UTC
(Gregorian).
| |||||||||||
Returns the
Era designated by the era name that
has to be known to this calendar system. | |||||||||||
Returns valid
Era s of this calendar system. | |||||||||||
Returns the singleton instance of the
Gregorian
calendar system. | |||||||||||
Returns the length in days of the month specified by the calendar
date.
| |||||||||||
Returns the name of this calendar system.
| |||||||||||
Returns a
CalendarDate of the n-th day of week
which is on, after or before the specified date. | |||||||||||
Returns the number of milliseconds since the Epoch, January 1,
1970 00:00:00 UTC (Gregorian), represented by the specified
CalendarDate . | |||||||||||
Returns the length in days of a week in this calendar
system.
| |||||||||||
Returns the length in days of the specified year by
date . | |||||||||||
Returns the number of months of the specified year.
| |||||||||||
Constructs a
CalendarDate that is specific to this
calendar system. | |||||||||||
Normalizes calendar fields in the specified
date . | |||||||||||
Checks whether the calendar fields specified by
date
represents a valid date and time in this calendar system. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Returns a CalendarSystem
specified by the calendar
name. The calendar name has to be one of the supported calendar
names.
calendarName | the calendar name |
---|
CalendarSystem
specified by
calendarName
, or null if there is no
CalendarSystem
associated with the given calendar name.
Calculates calendar fields from the specified number of milliseconds since the Epoch, January 1, 1970 00:00:00 UTC (Gregorian). This method doesn't check overflow or underflow when adjusting the millisecond value (representing UTC) with the time zone offsets (i.e., the GMT offset and amount of daylight saving).
millis | the offset value in milliseconds from January 1, 1970 00:00:00 UTC (Gregorian). |
---|
CalendarDate
instance that contains the
calculated calendar field values.
Returns the Era
designated by the era name that
has to be known to this calendar system. If no Era is
applicable to this calendar system, null is returned.
eraName | the name of the era |
---|
Era
designated by
eraName
, or null
if no Era is
applicable to this calendar system or the specified era name is
not known to this calendar system.
Returns valid Era
s of this calendar system. The
return value is sorted in the descendant order. (i.e., the first
element of the returned array is the oldest era.) If no era is
applicable to this calendar system, null
is returned.
Era
s, or
null
if no era is applicable to this calendar
system.
Returns the singleton instance of the Gregorian
calendar system.
Gregorian
instance
Returns the length in days of the month specified by the calendar
date. This method does not perform the normalization with the
specified calendar date. The CalendarDate
must
be normalized to get a correct value.
date | the date from which the month value is obtained |
---|
IllegalArgumentException | if the specified calendar date doesn't have a valid month value in this calendar system. |
---|
Returns a CalendarDate
of the n-th day of week
which is on, after or before the specified date. For example, the
first Sunday in April 2002 (Gregorian) can be obtained as
below:
Gregorian cal = CalendarSystem.getGregorianCalendar();
CalendarDate date = cal.newCalendarDate();
date.setDate(2004, cal.APRIL, 1);
CalendarDate firstSun = cal.getNthDayOfWeek(1, cal.SUNDAY, date);
// firstSun represents April 4, 2004.
This method returns a new CalendarDate
instance
and doesn't modify the original date.nth | specifies the n-th one. A positive number specifies
on or after the date . A non-positive number
specifies on or before the date . |
---|---|
dayOfWeek | the day of week |
date | the date |
dayOfWeek
after
or before the specified CalendarDate
Returns the number of milliseconds since the Epoch, January 1,
1970 00:00:00 UTC (Gregorian), represented by the specified
CalendarDate
.
date | the CalendarDate from which the time
value is calculated |
---|
Returns the length in days of a week in this calendar system. If this calendar system has multiple radix weeks, this method returns only one of them.
Returns the length in days of the specified year by
date
. This method does not perform the
normalization with the specified CalendarDate
. The
CalendarDate
must be normalized to get a correct
value.
Returns the number of months of the specified year. This method
does not perform the normalization with the specified
CalendarDate
. The CalendarDate
must
be normalized to get a correct value.
Constructs a CalendarDate
that is specific to this
calendar system. All calendar fields have their initial
values. The default time zone
is
set to the instance.
CalendarDate
instance that contains the initial
calendar field values.
Normalizes calendar fields in the specified
date
. Also all undefined
fields are set to correct values. The actual
normalization process is calendar system dependent.
date | the calendar date to be validated |
---|
true
if all fields have been normalized;
false
otherwise.NullPointerException | if the specified
date is null
|
---|
IllegalArgumentException | if the specified era name is unknown to this calendar system. |
---|
Checks whether the calendar fields specified by date
represents a valid date and time in this calendar system. If the
given date is valid, date
is marked as normalized.
date | the CalendarDate to be validated |
---|
true
if all the calendar fields are consistent,
otherwise, false
is returned.NullPointerException | if the specified
date is null
|
---|