public abstract class Calendar extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
static int |
AM |
static int |
AM_PM |
static int |
APRIL |
protected boolean |
areFieldsSet |
static int |
AUGUST |
static int |
DATE |
static int |
DAY_OF_MONTH |
static int |
DAY_OF_WEEK |
static int |
DAY_OF_WEEK_IN_MONTH |
static int |
DAY_OF_YEAR |
static int |
DECEMBER |
static int |
DST_OFFSET |
static int |
ERA |
static int |
FEBRUARY |
static int |
FRIDAY |
static int |
HOUR |
static int |
HOUR_OF_DAY |
protected boolean[] |
isParamSet |
protected boolean |
isTimeSet |
static int |
JANUARY |
static int |
JULY |
static int |
JUNE |
static int |
MARCH |
static int |
MAY |
static int |
MILLISECOND |
static int |
MINUTE |
static int |
MONDAY |
static int |
MONTH |
static int |
NOVEMBER |
static int |
OCTOBER |
static int |
PARAM_COUNT |
static int |
PM |
static int |
SATURDAY |
static int |
SECOND |
static int |
SEPTEMBER |
static int |
SUNDAY |
static int |
THURSDAY |
protected long |
time |
static int |
TUESDAY |
protected int[] |
tzParams |
static int |
UNDECIMBER |
static int |
WEDNESDAY |
static int |
WEEK_OF_MONTH |
static int |
WEEK_OF_YEAR |
static int |
YEAR |
static int |
ZONE_OFFSET |
Constructor and Description |
---|
Calendar()
Constructs a Calendar with the default time zone.
|
Calendar(TimeZone timezone)
Constructs a calendar with the specified time zone.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
add(int field,
int amount)
Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules.
|
abstract boolean |
after(Object when)
Returns whether this Calendar represents a time after the time represented by the specified Object.
|
abstract boolean |
before(Object when)
Returns whether this Calendar represents a time before the time represented by the specified Object.
|
void |
clear()
Sets all the calendar field values and the time value (millisecond offset from the Epoch) of this Calendar undefined.
|
void |
clear(int field)
Sets the given calendar field value and the time value (millisecond offset from the Epoch) of this Calendar undefined.
|
Object |
clone()
Creates a new object of the same class as this object.
|
protected void |
complete()
Fills in any unset tzParams in the calendar tzParams.
|
protected abstract void |
computeFields()
Converts the current millisecond time value time to calendar field values in tzParams[].
|
protected abstract void |
computeTime()
Converts the current calendar field values in tzParams[] to the millisecond time value time.
|
abstract boolean |
equals(Object obj)
Compares two Objects for equality.
|
int |
get(int field)
Returns the value of the given calendar field.
|
int |
getFirstDayOfWeek()
Gets what the first day of the week is; e.g., SUNDAY in the U.S., MONDAY in France.
|
abstract int |
getGreatestMinimum(int field)
Returns the highest minimum value for the given calendar field of this Calendar instance.
|
static Calendar |
getInstance()
Gets a calendar using the default time zone.
|
static Calendar |
getInstance(TimeZone timezone)
Gets a calendar using the specified time zone.
|
abstract int |
getLeastMaximum(int field)
Returns the lowest maximum value for the given calendar field of this Calendar instance.
|
abstract int |
getMaximum(int field)
Returns the maximum value for the given calendar field of this Calendar instance.
|
int |
getMinimalDaysInFirstWeek()
Gets what the minimal days required in the first week of the year are.
|
abstract int |
getMinimum(int field)
Returns the minimum value for the given calendar field of this Calendar instance.
|
Date |
getTime()
Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").
|
protected long |
getTimeInMillis()
Returns this Calendar's time value in milliseconds.
|
TimeZone |
getTimeZone()
Gets the time zone.
|
protected int |
internalGet(int field)
Returns the value of the given calendar field.
|
boolean |
isLenient()
Tells whether date/time interpretation is to be lenient.
|
boolean |
isSet(int field)
Determines if the given calendar field has a value set, including cases that the value has
been set by internal tzParams calculations triggered by a get method call.
|
abstract void |
roll(int field,
boolean up)
Adds or subtracts (up/down) a single unit of time on the given time field without changing larger tzParams.
|
void |
set(int field,
int value)
Sets the given calendar field to the given value.
|
void |
set(int year,
int month,
int day)
Sets the values for the tzParams YEAR, MONTH, and DAY_OF_MONTH.
|
void |
set(int year,
int month,
int day,
int hours,
int mins)
Sets the values for the tzParams YEAR, MONTH, DAY_OF_MONTH, HOUR and MINUTE.
|
void |
set(int year,
int month,
int day,
int hours,
int mins,
int secs)
Sets the values for the tzParams YEAR, MONTH, DAY_OF_MONTH, HOUR, MINUTE, and SECOND.
|
void |
setFirstDayOfWeek(int dow)
Sets what the first day of the week is.
|
void |
setLenient(boolean flag)
Specifies whether or not date/time interpretation is to be lenient.
|
void |
setMinimalDaysInFirstWeek(int value)
Sets what the minimal days required in the first week of the year are.
|
void |
setTime(Date date)
Sets this Calendar's time with the given Date.
|
void |
setTimeInMillis(long ref)
Sets this Calendar's current time from the given long value.
|
void |
setTimeZone(TimeZone timezone)
Sets the time zone with the given time zone value.
|
public static final int PARAM_COUNT
public static final int ERA
public static final int YEAR
public static final int MONTH
public static final int WEEK_OF_YEAR
public static final int WEEK_OF_MONTH
public static final int DATE
public static final int DAY_OF_MONTH
public static final int DAY_OF_YEAR
public static final int DAY_OF_WEEK
public static final int DAY_OF_WEEK_IN_MONTH
public static final int AM_PM
public static final int HOUR
public static final int HOUR_OF_DAY
public static final int MINUTE
public static final int SECOND
public static final int MILLISECOND
public static final int ZONE_OFFSET
public static final int DST_OFFSET
public static final int AM
public static final int PM
public static final int JANUARY
public static final int FEBRUARY
public static final int MARCH
public static final int APRIL
public static final int MAY
public static final int JUNE
public static final int JULY
public static final int AUGUST
public static final int SEPTEMBER
public static final int OCTOBER
public static final int NOVEMBER
public static final int DECEMBER
public static final int UNDECIMBER
public static final int SUNDAY
public static final int MONDAY
public static final int TUESDAY
public static final int WEDNESDAY
public static final int THURSDAY
public static final int FRIDAY
public static final int SATURDAY
protected int[] tzParams
protected boolean[] isParamSet
protected long time
protected boolean isTimeSet
protected boolean areFieldsSet
public Calendar()
public Calendar(TimeZone timezone)
timezone
- the time zone to usepublic abstract void add(int field, int amount)
field
- the calendar field.amount
- the amount of date or time to be added to the field.public abstract boolean after(Object when)
when
- the Object to be comparedpublic abstract boolean before(Object when)
when
- the Object to be comparedpublic final void clear()
public final void clear(int field)
field
- the calendar field to be cleared.public Object clone()
Object
The clone
method of class Object
will
only clone an object whose class indicates that it is willing for
its instances to be cloned. A class indicates that its instances
can be cloned by declaring that it implements the
Cloneable
interface.
protected void complete()
protected abstract void computeFields()
protected abstract void computeTime()
public abstract boolean equals(Object obj)
Object
The equals
method implements an equivalence relation:
x
,
x.equals(x)
should return true
.
x
and
y
, x.equals(y)
should return
true
if and only if y.equals(x)
returns
true
.
x
,
y
, and z
, if x.equals(y)
returns true
and y.equals(z)
returns
true
, then x.equals(z)
should return
true
.
x
and y
, multiple invocations of x.equals(y)
consistently return true
or consistently return
false
.
x
, x.equals(null)
should return false
.
The equals method for class Object
implements the most
discriminating possible equivalence relation on objects; that is,
for any reference values x
and y
, this
method returns true
if and only if x
and
y
refer to the same object (x==y
has the
value true
).
equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Boolean.hashCode()
,
Hashtable
public final int get(int field)
field
- the given calendar fieldpublic int getFirstDayOfWeek()
public abstract int getGreatestMinimum(int field)
field
- the calendar field.public static Calendar getInstance()
public static Calendar getInstance(TimeZone timezone)
timezone
- the time zone to usepublic abstract int getLeastMaximum(int field)
field
- the calendar field.public abstract int getMaximum(int field)
field
- the calendar field.public int getMinimalDaysInFirstWeek()
public abstract int getMinimum(int field)
field
- the calendar field.public final Date getTime()
protected long getTimeInMillis()
public TimeZone getTimeZone()
protected final int internalGet(int field)
field
- the given calendar field.public boolean isLenient()
public final boolean isSet(int field)
field
- the field of interestpublic abstract void roll(int field, boolean up)
field
- the time field.up
- indicates if the value of the specified time field is to be rolled up or rolled down. Use true if rolling up, false otherwise.public final void set(int field, int value)
field
- the given calendar field.value
- the value to be set for the given calendar field.public final void set(int year, int month, int day)
year
- the value used to set the YEAR calendar field.month
- the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.day
- the value used to set the DAY_OF_MONTH calendar field.public final void set(int year, int month, int day, int hours, int mins)
year
- the value used to set the YEAR calendar field.month
- the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.day
- the value used to set the DAY_OF_MONTH calendar field.hours
- the value used to set the HOUR_OF_DAY calendar field.mins
- the value used to set the MINUTE calendar field.public final void set(int year, int month, int day, int hours, int mins, int secs)
year
- the value used to set the YEAR calendar field.month
- the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.day
- the value used to set the DAY_OF_MONTH calendar field.hours
- the value used to set the HOUR_OF_DAY calendar field.mins
- the value used to set the MINUTE calendar field.secs
- the value used to set the SECOND calendar field.public void setFirstDayOfWeek(int dow)
dow
- the given first day of the week.public void setLenient(boolean flag)
flag
- true if the lenient mode is to be turned on; false if it is to be turned off.public void setMinimalDaysInFirstWeek(int value)
value
- the given minimal days required in the first week of the year.public final void setTime(Date date)
date
- the given Date.public void setTimeInMillis(long ref)
ref
- the new time in UTC milliseconds from the epoch.public void setTimeZone(TimeZone timezone)
timezone
- the given time zone.