public abstract class

AbstractCalendar

extends CalendarSystem
java.lang.Object
   ↳ sun.util.calendar.CalendarSystem
     ↳ sun.util.calendar.AbstractCalendar
Known Direct Subclasses
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

Protected Constructors
AbstractCalendar()
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 Eras 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)
Protected Methods
abstract void getCalendarDateFromFixedDate(CalendarDate date, long fixedDate)
Calculates calendar fields from the specified fixed date.
abstract long getFixedDate(CalendarDate date)
Returns the fixed date calculated with the specified calendar date.
long getTimeOfDay(CalendarDate date)
abstract boolean isLeapYear(CalendarDate date)
void setEras(Era[] eras)
[Expand]
Inherited Methods
From class sun.util.calendar.CalendarSystem
From class java.lang.Object

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 CalendarDate getCalendarDate (long millis, CalendarDate date)

public CalendarDate getCalendarDate (long millis, TimeZone zone)

public CalendarDate getCalendarDate ()

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
Returns
  • the calculated date

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 Eras 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 Eras, 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 long getTimeOfDayValue (CalendarDate date)

public int getWeekLength ()

Returns 7 in this default implementation.

Returns
  • 7

public void setEra (CalendarDate date, String eraName)

public CalendarDate setTimeOfDay (CalendarDate cdate, int fraction)

public boolean validateTime (CalendarDate date)

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 long getTimeOfDay (CalendarDate date)

protected abstract boolean isLeapYear (CalendarDate date)

protected void setEras (Era[] eras)