public abstract class AbstractCalendar extends CalendarSystem
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.)
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCalendar() |
| Modifier and Type | Method and Description |
|---|---|
CalendarDate |
getCalendarDate() |
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,
java.util.TimeZone zone) |
protected abstract void |
getCalendarDateFromFixedDate(CalendarDate date,
long fixedDate)
Calculates calendar fields from the specified fixed date.
|
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(java.lang.String eraName)
Returns the
Era designated by the era name that
has to be known to this calendar system. |
Era[] |
getEras()
Returns valid
Eras of this calendar system. |
protected abstract long |
getFixedDate(CalendarDate date)
Returns the fixed date calculated with the specified calendar
date.
|
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. |
protected long |
getTimeOfDay(CalendarDate date) |
long |
getTimeOfDayValue(CalendarDate date) |
int |
getWeekLength()
Returns 7 in this default implementation.
|
protected abstract boolean |
isLeapYear(CalendarDate date) |
void |
setEra(CalendarDate date,
java.lang.String eraName) |
protected void |
setEras(Era[] eras) |
CalendarDate |
setTimeOfDay(CalendarDate cdate,
int fraction) |
boolean |
validateTime(CalendarDate date) |
forName, getGregorianCalendar, getMonthLength, getName, getYearLength, getYearLengthInMonths, newCalendarDate, newCalendarDate, normalize, validatepublic Era getEra(java.lang.String eraName)
CalendarSystemEra 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.getEra in class CalendarSystemeraName - the name of the eraEra 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()
CalendarSystemEras 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.getEras in class CalendarSystemEras, or
null if no era is applicable to this calendar
system.public void setEra(CalendarDate date, java.lang.String eraName)
setEra in class CalendarSystemEraprotected void setEras(Era[] eras)
public CalendarDate getCalendarDate()
getCalendarDate in class CalendarSystempublic CalendarDate getCalendarDate(long millis)
CalendarSystemgetCalendarDate in class CalendarSystemmillis - the offset value in milliseconds from January 1,
1970 00:00:00 UTC (Gregorian).CalendarDate instance that contains the
calculated calendar field values.public CalendarDate getCalendarDate(long millis, java.util.TimeZone zone)
getCalendarDate in class CalendarSystempublic CalendarDate getCalendarDate(long millis, CalendarDate date)
getCalendarDate in class CalendarSystempublic long getTime(CalendarDate date)
CalendarSystemCalendarDate.getTime in class CalendarSystemdate - the CalendarDate from which the time
value is calculatedprotected long getTimeOfDay(CalendarDate date)
public long getTimeOfDayValue(CalendarDate date)
public CalendarDate setTimeOfDay(CalendarDate cdate, int fraction)
setTimeOfDay in class CalendarSystempublic int getWeekLength()
getWeekLength in class CalendarSystemprotected abstract boolean isLeapYear(CalendarDate date)
public CalendarDate getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date)
CalendarSystemCalendarDate 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.getNthDayOfWeek in class CalendarSystemnth - 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 weekdate - the datedayOfWeek after
or before the specified CalendarDatepublic static long getDayOfWeekDateOnOrBefore(long fixedDate,
int dayOfWeek)
fixedDate - the fixed datedayOfWeek - the day of weekprotected abstract long getFixedDate(CalendarDate date)
date - a CalendarDate with which the fixed
date is calculatedAbstractCalendar.html#fixed_dateprotected abstract void getCalendarDateFromFixedDate(CalendarDate date, long fixedDate)
CalendarDate.date - a CalendarDate to stored the
calculated calendar fields.fixedDate - a fixed date to calculate calendar fieldsAbstractCalendar.html#fixed_datepublic boolean validateTime(CalendarDate date)