public abstract class CalendarDate
extends java.lang.Object
implements java.lang.Cloneable
CalendarDate class represents a specific instant
in time by calendar date and time fields that are multiple cycles
in different time unites. The semantics of each calendar field is
given by a concrete calendar system rather than this
CalendarDate class that holds calendar field values
without interpreting them. Therefore, this class can be used to
represent an amount of time, such as 2 years and 3 months.
A CalendarDate instance can be created by calling
the newCalendarDate or getCalendarDate
methods in CalendarSystem. A
CalendarSystem instance is obtained by calling one of
the factory methods in CalendarSystem. Manipulations
of calendar dates must be handled by the calendar system by which
CalendarDate instances have been created.
Some calendar fields can be modified through method calls. Any
modification of a calendar field brings the state of a
CalendarDate to not normalized. The
normalization must be performed to make all the calendar fields
consistent with a calendar system.
The protected methods are intended to be used for
implementing a concrete calendar system, not for general use as an
API.
CalendarSystem| Modifier and Type | Field and Description |
|---|---|
static int |
FIELD_UNDEFINED |
static long |
TIME_UNDEFINED |
| Modifier | Constructor and Description |
|---|---|
protected |
CalendarDate() |
protected |
CalendarDate(java.util.TimeZone zone) |
| Modifier and Type | Method and Description |
|---|---|
CalendarDate |
addDate(int year,
int month,
int dayOfMonth) |
CalendarDate |
addDayOfMonth(int n) |
CalendarDate |
addHours(int n) |
CalendarDate |
addMillis(int n) |
CalendarDate |
addMinutes(int n) |
CalendarDate |
addMonth(int n) |
CalendarDate |
addSeconds(int n) |
CalendarDate |
addTimeOfDay(int hours,
int minutes,
int seconds,
int millis) |
CalendarDate |
addYear(int n) |
java.lang.Object |
clone()
Returns a copy of this
CalendarDate. |
boolean |
equals(java.lang.Object obj) |
int |
getDaylightSaving() |
int |
getDayOfMonth() |
int |
getDayOfWeek()
Returns the day of week value.
|
Era |
getEra() |
int |
getHours() |
int |
getMillis() |
int |
getMinutes() |
int |
getMonth() |
int |
getSeconds() |
long |
getTimeOfDay() |
int |
getYear() |
java.util.TimeZone |
getZone() |
int |
getZoneOffset() |
int |
hashCode() |
boolean |
isDaylightTime() |
boolean |
isLeapYear()
Returns whether the year represented by this
CalendarDate is a leap year. |
boolean |
isNormalized() |
boolean |
isSameDate(CalendarDate date)
Returns whether the specified date is the same date of this
CalendarDate. |
boolean |
isStandardTime() |
CalendarDate |
setDate(int year,
int month,
int dayOfMonth) |
protected void |
setDaylightSaving(int daylightSaving) |
CalendarDate |
setDayOfMonth(int date) |
protected void |
setDayOfWeek(int dayOfWeek) |
CalendarDate |
setEra(Era era)
Sets the era of the date to the specified era.
|
CalendarDate |
setHours(int hours) |
protected void |
setLocale(java.util.Locale loc) |
CalendarDate |
setMillis(int millis) |
CalendarDate |
setMinutes(int minutes) |
CalendarDate |
setMonth(int month) |
protected void |
setNormalized(boolean normalized) |
CalendarDate |
setSeconds(int seconds) |
void |
setStandardTime(boolean standardTime) |
CalendarDate |
setTimeOfDay(int hours,
int minutes,
int seconds,
int millis) |
protected void |
setTimeOfDay(long fraction) |
CalendarDate |
setYear(int year) |
CalendarDate |
setZone(java.util.TimeZone zoneinfo) |
protected void |
setZoneOffset(int offset) |
java.lang.String |
toString()
Converts calendar date values to a
String in the
following format. |
public static final int FIELD_UNDEFINED
public static final long TIME_UNDEFINED
protected CalendarDate()
protected CalendarDate(java.util.TimeZone zone)
public Era getEra()
public CalendarDate setEra(Era era)
null.java.lang.NullPointerException - if the calendar system for this
CalendarDate requires eras and the specified era
is null.java.lang.IllegalArgumentException - if the specified
era is unknown to the calendar
system for this CalendarDate.public int getYear()
public CalendarDate setYear(int year)
public CalendarDate addYear(int n)
public boolean isLeapYear()
CalendarDate is a leap year. If leap years are
not applicable to the calendar system, this method always
returns false.
If this CalendarDate hasn't been normalized,
false is returned. The normalization must be
performed to retrieve the correct leap year information.
true if this CalendarDate is
normalized and the year of this CalendarDate is a
leap year, or false otherwise.BaseCalendar#isGregorianLeapYearpublic int getMonth()
public CalendarDate setMonth(int month)
public CalendarDate addMonth(int n)
public int getDayOfMonth()
public CalendarDate setDayOfMonth(int date)
public CalendarDate addDayOfMonth(int n)
public int getDayOfWeek()
FIELD_UNDEFINED is returned.FIELD_UNDEFINEDpublic int getHours()
public CalendarDate setHours(int hours)
public CalendarDate addHours(int n)
public int getMinutes()
public CalendarDate setMinutes(int minutes)
public CalendarDate addMinutes(int n)
public int getSeconds()
public CalendarDate setSeconds(int seconds)
public CalendarDate addSeconds(int n)
public int getMillis()
public CalendarDate setMillis(int millis)
public CalendarDate addMillis(int n)
public long getTimeOfDay()
public CalendarDate setDate(int year, int month, int dayOfMonth)
public CalendarDate addDate(int year, int month, int dayOfMonth)
public CalendarDate setTimeOfDay(int hours, int minutes, int seconds, int millis)
public CalendarDate addTimeOfDay(int hours, int minutes, int seconds, int millis)
protected void setTimeOfDay(long fraction)
public boolean isNormalized()
public boolean isStandardTime()
public void setStandardTime(boolean standardTime)
public boolean isDaylightTime()
protected void setLocale(java.util.Locale loc)
public java.util.TimeZone getZone()
public CalendarDate setZone(java.util.TimeZone zoneinfo)
public boolean isSameDate(CalendarDate date)
CalendarDate. The time of the day fields are
ignored for the comparison.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object clone()
CalendarDate. The
TimeZone object, if any, is not cloned.clone in class java.lang.ObjectCalendarDatepublic java.lang.String toString()
String in the
following format.
yyyy-MM-dd'T'HH:mm:ss.SSSz
toString in class java.lang.ObjectSimpleDateFormatprotected void setDayOfWeek(int dayOfWeek)
protected void setNormalized(boolean normalized)
public int getZoneOffset()
protected void setZoneOffset(int offset)
public int getDaylightSaving()
protected void setDaylightSaving(int daylightSaving)