APIdia Launch Partner
Top Description Fields Constructors Methods
sun.util.calendar

public abstract sealed Class AbstractCalendar

extends CalendarSystem
permits BaseCalendar
Class Inheritance
Known Direct Subclasses
sun.util.calendar.BaseCalendar
Imports
java.util.TimeZone

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.)

Author
Masayoshi Okutsu
Since
1.5

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
private Era[]
pack-priv static final int
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public CalendarDate
public CalendarDate
getCalendarDate(long millis)

Implements abstract sun.util.calendar.CalendarSystem.getCalendarDate.

Calculates calendar fields from the specified number of milliseconds since the Epoch, January 1, 1970 00:00:00 UTC (Gregorian).

public CalendarDate
public CalendarDate
protected abstract void
getCalendarDateFromFixedDate(CalendarDate
a CalendarDate to store the calculated calendar fields.
date
,
long
a fixed date to calculate calendar fields
fixedDate
)

Calculates calendar fields from the specified fixed date.

pack-priv static long

Returns:

the calculated date
getDayOfWeekDateAfter
(long
the fixed date
fixedDate
,
int
the day of week
dayOfWeek
)

Returns a date of the given day of week that is closest to and after the given fixed date.

pack-priv static long

Returns:

the calculated date
getDayOfWeekDateBefore
(long
the fixed date
fixedDate
,
int
the day of week
dayOfWeek
)

Returns a date of the given day of week before the given fixed date.

public static long

Returns:

the calculated date
getDayOfWeekDateOnOrBefore
(long
the fixed date
fixedDate
,
int
the day of week
dayOfWeek
)

Returns a date of the given day of week on or before the given fixed date.

public Era
getEra(String eraName)

Implements abstract sun.util.calendar.CalendarSystem.getEra.

Returns the Era designated by the era name that has to be known to this calendar system.

public Era[]
getEras()

Implements abstract sun.util.calendar.CalendarSystem.getEras.

Returns valid Eras of this calendar system.

protected abstract long

Returns:

the calculated fixed date
getFixedDate
(CalendarDate
a CalendarDate with which the fixed date is calculated
date
)

Returns the fixed date calculated with the specified calendar date.

public CalendarDate
getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date)

Implements abstract sun.util.calendar.CalendarSystem.getNthDayOfWeek.

Returns a CalendarDate of the n-th day of week which is on, after or before the specified date.

public long
getTime(CalendarDate date)

Implements abstract sun.util.calendar.CalendarSystem.getTime.

Returns the number of milliseconds since the Epoch, January 1, 1970 00:00:00 UTC (Gregorian), represented by the specified CalendarDate.

protected long
public long
protected abstract boolean
pack-priv int
protected void
setEras(Era[] eras)

public CalendarDate
public boolean
Inherited from sun.util.calendar.CalendarSystem:
forNamegetGregorianCalendargetMonthLengthgetNamegetYearLengthnewCalendarDatenewCalendarDatenormalizevalidate

Field Detail

DAY_IN_MILLISback to summary
pack-priv static final int DAY_IN_MILLIS
EPOCH_OFFSETback to summary
pack-priv static final int EPOCH_OFFSET
erasback to summary
private Era[] eras
HOUR_IN_MILLISback to summary
pack-priv static final int HOUR_IN_MILLIS
MINUTE_IN_MILLISback to summary
pack-priv static final int MINUTE_IN_MILLIS
SECOND_IN_MILLISback to summary
pack-priv static final int SECOND_IN_MILLIS

Constructor Detail

AbstractCalendarback to summary
protected AbstractCalendar()

Method Detail

getCalendarDateback to summary
public CalendarDate getCalendarDate()

Implements abstract sun.util.calendar.CalendarSystem.getCalendarDate.

Annotations
@Override
getCalendarDateback to summary
public CalendarDate getCalendarDate(long millis)

Implements abstract sun.util.calendar.CalendarSystem.getCalendarDate.

Doc from sun.util.calendar.CalendarSystem.getCalendarDate.

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).

Annotations
@Override
getCalendarDateback to summary
public CalendarDate getCalendarDate(long millis, TimeZone zone)

Implements abstract sun.util.calendar.CalendarSystem.getCalendarDate.

Annotations
@Override
getCalendarDateback to summary
public CalendarDate getCalendarDate(long millis, CalendarDate date)

Implements abstract sun.util.calendar.CalendarSystem.getCalendarDate.

Annotations
@Override
getCalendarDateFromFixedDateback to summary
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:CalendarDate

a CalendarDate to store the calculated calendar fields.

fixedDate:long

a fixed date to calculate calendar fields

See Also
AbstractCalendar.html#fixed_date
getDayOfWeekDateAfterback to summary
pack-priv static long getDayOfWeekDateAfter(long fixedDate, int dayOfWeek)

Returns a date of the given day of week that is closest to and after the given fixed date.

Parameters
fixedDate:long

the fixed date

dayOfWeek:int

the day of week

Returns:long

the calculated date

getDayOfWeekDateBeforeback to summary
pack-priv static long getDayOfWeekDateBefore(long fixedDate, int dayOfWeek)

Returns a date of the given day of week before the given fixed date.

Parameters
fixedDate:long

the fixed date

dayOfWeek:int

the day of week

Returns:long

the calculated date

getDayOfWeekDateOnOrBeforeback to summary
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:long

the fixed date

dayOfWeek:int

the day of week

Returns:long

the calculated date

getEraback to summary
public Era getEra(String eraName)

Implements abstract sun.util.calendar.CalendarSystem.getEra.

Doc from sun.util.calendar.CalendarSystem.getEra.

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.

Annotations
@Override
getErasback to summary
public Era[] getEras()

Implements abstract sun.util.calendar.CalendarSystem.getEras.

Doc from sun.util.calendar.CalendarSystem.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.

Annotations
@Override
getFixedDateback to summary
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:CalendarDate

a CalendarDate with which the fixed date is calculated

Returns:long

the calculated fixed date

See Also
AbstractCalendar.html#fixed_date
getNthDayOfWeekback to summary
public CalendarDate getNthDayOfWeek(int nth, int dayOfWeek, CalendarDate date)

Implements abstract sun.util.calendar.CalendarSystem.getNthDayOfWeek.

Doc from sun.util.calendar.CalendarSystem.getNthDayOfWeek.

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.
Annotations
@Override
getTimeback to summary
public long getTime(CalendarDate date)

Implements abstract sun.util.calendar.CalendarSystem.getTime.

Doc from sun.util.calendar.CalendarSystem.getTime.

Returns the number of milliseconds since the Epoch, January 1, 1970 00:00:00 UTC (Gregorian), represented by the specified CalendarDate.

Annotations
@Override
getTimeOfDayback to summary
protected long getTimeOfDay(CalendarDate date)
getTimeOfDayValueback to summary
public long getTimeOfDayValue(CalendarDate date)
isLeapYearback to summary
protected abstract boolean isLeapYear(CalendarDate date)
normalizeTimeback to summary
pack-priv int normalizeTime(CalendarDate date)
setErasback to summary
protected void setEras(Era[] eras)
setTimeOfDayback to summary
public CalendarDate setTimeOfDay(CalendarDate cdate, int fraction)

Implements abstract sun.util.calendar.CalendarSystem.setTimeOfDay.

validateTimeback to summary
public boolean validateTime(CalendarDate date)