Known Direct Subclasses
BaseCalendar |
The BaseCalendar provides basic calendar calculation
functions to support the Julian, Gregorian, and Gregorian-based
calendar systems. |
|
Known Indirect Subclasses
|
Class Overview
The AbstractCalendar
class provides a framework for
implementing a concrete calendar system.
Fixed Date
For implementing a concrete calendar system, each calendar must
have the common date numbering, starting from midnight the onset of
Monday, January 1, 1 (Gregorian). It is called a fixed date
in this class. January 1, 1 (Gregorian) is fixed date 1. (See
Nachum Dershowitz and Edward M. Reingold, CALENDRICAL
CALCULATION The Millennium Edition, Section 1.2 for details.)
Summary
Public Methods |
CalendarDate
|
getCalendarDate(long millis)
Calculates calendar fields from the specified number of
milliseconds since the Epoch, January 1, 1970 00:00:00 UTC
(Gregorian).
|
CalendarDate
|
getCalendarDate(long millis, CalendarDate date)
|
CalendarDate
|
getCalendarDate(long millis, TimeZone zone)
|
CalendarDate
|
getCalendarDate()
|
static
long
|
getDayOfWeekDateOnOrBefore(long fixedDate, int dayOfWeek)
Returns a date of the given day of week on or before the given fixed
date.
|
Era
|
getEra(String eraName)
Returns the Era designated by the era name that
has to be known to this calendar system.
|
Era[]
|
getEras()
Returns valid Era s of this calendar system.
|
CalendarDate
|
getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date)
Returns a CalendarDate of the n-th day of week
which is on, after or before the specified date.
|
long
|
getTime(CalendarDate date)
Returns the number of milliseconds since the Epoch, January 1,
1970 00:00:00 UTC (Gregorian), represented by the specified
CalendarDate .
|
long
|
getTimeOfDayValue(CalendarDate date)
|
int
|
getWeekLength()
Returns 7 in this default implementation.
|
void
|
setEra(CalendarDate date, String eraName)
|
CalendarDate
|
setTimeOfDay(CalendarDate cdate, int fraction)
|
boolean
|
validateTime(CalendarDate date)
|
[Expand]
Inherited Methods |
From class
sun.util.calendar.CalendarSystem
static
CalendarSystem
|
forName(String calendarName)
Returns a CalendarSystem specified by the calendar
name.
|
abstract
CalendarDate
|
getCalendarDate(long millis)
Calculates calendar fields from the specified number of
milliseconds since the Epoch, January 1, 1970 00:00:00 UTC
(Gregorian).
|
abstract
CalendarDate
|
getCalendarDate(long millis, CalendarDate date)
|
abstract
CalendarDate
|
getCalendarDate(long millis, TimeZone zone)
|
abstract
CalendarDate
|
getCalendarDate()
|
abstract
Era
|
getEra(String eraName)
Returns the Era designated by the era name that
has to be known to this calendar system.
|
abstract
Era[]
|
getEras()
Returns valid Era s of this calendar system.
|
static
Gregorian
|
getGregorianCalendar()
Returns the singleton instance of the Gregorian
calendar system.
|
abstract
int
|
getMonthLength(CalendarDate date)
Returns the length in days of the month specified by the calendar
date.
|
abstract
String
|
getName()
Returns the name of this calendar system.
|
abstract
CalendarDate
|
getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date)
Returns a CalendarDate of the n-th day of week
which is on, after or before the specified date.
|
abstract
long
|
getTime(CalendarDate date)
Returns the number of milliseconds since the Epoch, January 1,
1970 00:00:00 UTC (Gregorian), represented by the specified
CalendarDate .
|
abstract
int
|
getWeekLength()
Returns the length in days of a week in this calendar
system.
|
abstract
int
|
getYearLength(CalendarDate date)
Returns the length in days of the specified year by
date .
|
abstract
int
|
getYearLengthInMonths(CalendarDate date)
Returns the number of months of the specified year.
|
abstract
CalendarDate
|
newCalendarDate()
Constructs a CalendarDate that is specific to this
calendar system.
|
abstract
CalendarDate
|
newCalendarDate(TimeZone zone)
|
abstract
boolean
|
normalize(CalendarDate date)
Normalizes calendar fields in the specified
date .
|
abstract
void
|
setEra(CalendarDate date, String eraName)
|
abstract
CalendarDate
|
setTimeOfDay(CalendarDate date, int timeOfDay)
|
abstract
boolean
|
validate(CalendarDate date)
Checks whether the calendar fields specified by date
represents a valid date and time in this calendar system.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
Protected Constructors
protected
AbstractCalendar
()
Public Methods
public
CalendarDate
getCalendarDate
(long millis)
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).
Parameters
millis
| the offset value in milliseconds from January 1,
1970 00:00:00 UTC (Gregorian). |
Returns
- a
CalendarDate
instance that contains the
calculated calendar field values.
public
static
long
getDayOfWeekDateOnOrBefore
(long fixedDate, int dayOfWeek)
Returns a date of the given day of week on or before the given fixed
date.
Parameters
fixedDate
| the fixed date |
dayOfWeek
| the day of week |
public
Era
getEra
(String eraName)
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.
Parameters
eraName
| the name of the era |
Returns
- the
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.
public
Era[]
getEras
()
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.
Returns
- an array of valid
Era
s, or
null
if no era is applicable to this calendar
system.
public
CalendarDate
getNthDayOfWeek
(int nth, int dayOfWeek, CalendarDate date)
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.
Parameters
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 |
Returns
- the date of the nth
dayOfWeek
after
or before the specified CalendarDate
public
long
getTime
(CalendarDate date)
Returns the number of milliseconds since the Epoch, January 1,
1970 00:00:00 UTC (Gregorian), represented by the specified
CalendarDate
.
Parameters
date
| the CalendarDate from which the time
value is calculated |
Returns
- the number of milliseconds since the Epoch.
public
int
getWeekLength
()
Returns 7 in this default implementation.
Protected Methods
protected
abstract
void
getCalendarDateFromFixedDate
(CalendarDate date, long fixedDate)
Calculates calendar fields from the specified fixed date. This
method stores the calculated calendar field values in the specified
CalendarDate
.
Parameters
date
| a CalendarDate to stored the
calculated calendar fields. |
fixedDate
| a fixed date to calculate calendar fields |
See Also
- AbstractCalendar.html#fixed_date
protected
abstract
long
getFixedDate
(CalendarDate date)
Returns the fixed date calculated with the specified calendar
date. If the specified date is not normalized, its date fields
are normalized.
Parameters
date
| a CalendarDate with which the fixed
date is calculated |
Returns
- the calculated fixed date
See Also
- AbstractCalendar.html#fixed_date
protected
void
setEras
(Era[] eras)