public abstract class Calendar extends Object
Modifier and Type | Field and Description |
---|---|
static int |
AM
Value of the AM_PM field indicating the period of the day from midnight to just before noon.
|
static int |
AM_PM
Field number for get and set indicating whether the HOUR is before or after noon.
|
static int |
APRIL
Value of the MONTH field indicating the fourth month of the year.
|
static int |
AUGUST
Value of the MONTH field indicating the eighth month of the year.
|
static int |
DATE
Field number for get and set indicating the day of the month.
|
static int |
DAY_OF_MONTH
Field number for get and set indicating the day of the month.
|
static int |
DAY_OF_WEEK
Field number for get and set indicating the day of the week.
|
static int |
DAY_OF_WEEK_IN_MONTH
Field number for
get and set indicating the
ordinal number of the day of the week within the current month. |
static int |
DECEMBER
Value of the MONTH field indicating the twelfth month of the year.
|
static int |
FEBRUARY
Value of the MONTH field indicating the second month of the year.
|
protected int[] |
fields
The field values for the currently set time for this calendar.
|
static int |
FRIDAY
Value of the DAY_OF_WEEK field indicating Friday.
|
static int |
HOUR
Field number for get and set indicating the hour of the morning or afternoon.
|
static int |
HOUR_OF_DAY
Field number for get and set indicating the hour of the day.
|
protected boolean[] |
isSet
The flags which tell if a specified time field for the calendar is set.
|
static int |
JANUARY
Value of the MONTH field indicating the first month of the year.
|
static int |
JULY
Value of the MONTH field indicating the seventh month of the year.
|
static int |
JUNE
Value of the MONTH field indicating the sixth month of the year.
|
static int |
MARCH
Value of the MONTH field indicating the third month of the year.
|
static int |
MAY
Value of the MONTH field indicating the fifth month of the year.
|
static int |
MILLISECOND
Field number for get and set indicating the millisecond within the second.
|
static int |
MINUTE
Field number for get and set indicating the minute within the hour.
|
static int |
MONDAY
Value of the DAY_OF_WEEK field indicating Monday.
|
static int |
MONTH
Field number for get and set indicating the month.
|
static int |
NOVEMBER
Value of the MONTH field indicating the eleventh month of the year.
|
static int |
OCTOBER
Value of the MONTH field indicating the tenth month of the year.
|
static int |
PM
Value of the AM_PM field indicating the period of the day from noon to just before midnight.
|
static int |
SATURDAY
Value of the DAY_OF_WEEK field indicating Saturday.
|
static int |
SECOND
Field number for get and set indicating the second within the minute.
|
static int |
SEPTEMBER
Value of the MONTH field indicating the ninth month of the year.
|
static int |
SUNDAY
Value of the DAY_OF_WEEK field indicating Sunday.
|
static int |
THURSDAY
Value of the DAY_OF_WEEK field indicating Thursday.
|
protected long |
time
The currently set time for this calendar, expressed in milliseconds after January 1, 1970, 0:00:00 GMT.
|
static int |
TUESDAY
Value of the DAY_OF_WEEK field indicating Tuesday.
|
static int |
WEDNESDAY
Value of the DAY_OF_WEEK field indicating Wednesday.
|
static int |
WEEK_OF_MONTH
Field number for
get and set indicating the
week number within the current month. |
static int |
WEEK_OF_YEAR
Field number for
get and set indicating the
week number within the current year. |
static int |
YEAR
Field number for get and set indicating the year.
|
Modifier | Constructor and Description |
---|---|
protected |
Calendar()
Constructs a Calendar with the default time zone.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int field,
int value)
Adds the specified amount to a
Calendar field. |
boolean |
after(Object when)
Compares the time field records.
|
boolean |
before(Object when)
Compares the time field records.
|
protected abstract void |
computeFields()
Converts the current millisecond time value time to field values in fields[].
|
protected abstract void |
computeTime()
Converts the current field values in fields[] to the millisecond time value time.
|
boolean |
equals(Object obj)
Compares this calendar to the specified object.
|
int |
get(int field)
Gets the value for a given time field.
|
static Calendar |
getInstance()
Gets a calendar using the default time zone.
|
static Calendar |
getInstance(TimeZone zone)
Gets a calendar using the specified time zone.
|
Date |
getTime()
Gets this Calendar's current time.
|
protected long |
getTimeInMillis()
Gets this Calendar's current time as a long expressed in milliseconds after January 1, 1970, 0:00:00 GMT (the epoch).
|
TimeZone |
getTimeZone()
Gets the time zone.
|
void |
set(int field,
int value)
Sets the time field with the given value.
|
void |
setTime(Date date)
Sets this Calendar's current time with the given Date.
|
protected void |
setTimeInMillis(long millis)
Sets this Calendar's current time from the given long value.
|
void |
setTimeZone(TimeZone value)
Sets the time zone with the given time zone value.
|
public static final int AM
public static final int AM_PM
public static final int APRIL
public static final int AUGUST
public static final int WEEK_OF_YEAR
get
and set
indicating the
week number within the current year. The first week of the year, as
defined by getFirstDayOfWeek()
and
getMinimalDaysInFirstWeek()
, has value 1. Subclasses
define the value of WEEK_OF_YEAR
for days before the first
week of the year.#getFirstDayOfWeek
,
#getMinimalDaysInFirstWeek
,
Constant Field Valuespublic static final int WEEK_OF_MONTH
get
and set
indicating the
week number within the current month. The first week of the month, as
defined by getFirstDayOfWeek()
and
getMinimalDaysInFirstWeek()
, has value 1. Subclasses
define the value of WEEK_OF_MONTH
for days before the
first week of the month.#getFirstDayOfWeek
,
#getMinimalDaysInFirstWeek
,
Constant Field Valuespublic static final int DATE
public static final int DAY_OF_MONTH
public static final int DAY_OF_WEEK
public static final int DAY_OF_WEEK_IN_MONTH
get
and set
indicating the
ordinal number of the day of the week within the current month. Together
with the DAY_OF_WEEK
field, this uniquely specifies a day
within a month. Unlike WEEK_OF_MONTH
and
WEEK_OF_YEAR
, this field's value does not
depend on getFirstDayOfWeek()
or
getMinimalDaysInFirstWeek()
. DAY_OF_MONTH 1
through 7
always correspond to DAY_OF_WEEK_IN_MONTH
1
;
8
through 15
correspond to
DAY_OF_WEEK_IN_MONTH 2
, and so on.
DAY_OF_WEEK_IN_MONTH 0
indicates the week before
DAY_OF_WEEK_IN_MONTH 1
. Negative values count back from
the end of the month, so the last Sunday of a month is specified as
DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1
. Because
negative values count backward they will usually be aligned differently
within the month than positive values. For example, if a month has 31
days, DAY_OF_WEEK_IN_MONTH -1
will overlap
DAY_OF_WEEK_IN_MONTH 5
and the end of 4
.DAY_OF_WEEK
,
WEEK_OF_MONTH
,
Constant Field Valuespublic static final int DECEMBER
public static final int FEBRUARY
protected int[] fields
public static final int FRIDAY
public static final int HOUR
public static final int HOUR_OF_DAY
protected boolean[] isSet
public static final int JANUARY
public static final int JULY
public static final int JUNE
public static final int MARCH
public static final int MAY
public static final int MILLISECOND
public static final int MINUTE
public static final int MONDAY
public static final int MONTH
public static final int NOVEMBER
public static final int OCTOBER
public static final int PM
public static final int SATURDAY
public static final int SECOND
public static final int SEPTEMBER
public static final int SUNDAY
public static final int THURSDAY
protected long time
public static final int TUESDAY
public static final int WEDNESDAY
public static final int YEAR
protected Calendar()
public boolean after(Object when)
public boolean before(Object when)
protected abstract void computeFields()
protected abstract void computeTime()
public boolean equals(Object obj)
public final int get(int field)
public static Calendar getInstance()
public static Calendar getInstance(TimeZone zone)
public final Date getTime()
protected long getTimeInMillis()
public TimeZone getTimeZone()
public final void set(int field, int value)
public final void add(int field, int value)
Calendar
field.field
- the Calendar
field to modify.value
- the amount to add to the field.IllegalArgumentException
- if field
is DST_OFFSET
or ZONE_OFFSET
.public final void setTime(Date date)
protected void setTimeInMillis(long millis)
public void setTimeZone(TimeZone value)