|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Calendar
public abstract class Calendar
Calendar is an abstract base class for converting between a Date object and a set of integer fields such as YEAR, MONTH, DAY, HOUR, and so on. (A Date object represents a specific instant in time with millisecond precision. See Date for information about the Date class.) Subclasses of Calendar interpret a Date according to the rules of a specific calendar system. Like other locale-sensitive classes, Calendar provides a class method, getInstance, for getting a generally useful object of this type. Calendar rightNow = Calendar.getInstance(); A Calendar object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). When computing a Date from time fields, there may be insufficient information to compute the Date (such as only year and month but no day in the month). Insufficient information. The calendar will use default information to specify the missing fields. This may vary by calendar; for the Gregorian calendar, the default for a field is the same as that of the start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc. Note: The ambiguity in interpretation of what day midnight belongs to, is resolved as so: midnight "belongs" to the following day. 23:59 on Dec 31, 1969 < 00:00 on Jan 1, 1970. 12:00 PM is midday, and 12:00 AM is midnight. 11:59 PM on Jan 1 < 12:00 AM on Jan 2 < 12:01 AM on Jan 2. 11:59 AM on Mar 10 < 12:00 PM on Mar 10 < 12:01 PM on Mar 10. 24:00 or greater are invalid. Hours greater than 12 are invalid in AM/PM mode. Setting the time will never change the date. If equivalent times are entered in AM/PM or 24 hour mode, equality will be determined by the actual time rather than the entered time. This class has been subset for J2ME based on the JDK 1.3 Calendar class. Many methods and variables have been pruned, and other methods simplified, in an effort to reduce the size of this class.
| Field Summary | |
|---|---|
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
|
static int |
AUGUST
|
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 |
DECEMBER
|
static int |
FEBRUARY
|
static int |
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. |
static int |
JANUARY
|
static int |
JULY
|
static int |
JUNE
|
static int |
MARCH
|
static int |
MAY
|
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
|
static int |
MONTH
Field number for get and set indicating the month. |
static int |
NOVEMBER
|
static int |
OCTOBER
|
static int |
PM
Value of the AM_PM field indicating the period of the day from noon to just before midnight. |
static int |
SATURDAY
|
static int |
SECOND
Field number for get and set indicating the second within the minute. |
static int |
SEPTEMBER
|
static int |
SUNDAY
|
static int |
THURSDAY
|
static int |
TUESDAY
|
static int |
WEDNESDAY
|
static int |
YEAR
Field number for get and set indicating the year. |
| Constructor Summary | |
|---|---|
protected |
Calendar()
Constructs a Calendar with the default time zone. |
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int AM_PM
public static final int PM
public static final int AM
public static final int YEAR
public static final int MONTH
public static final int DATE
public static final int DAY_OF_MONTH
public static final int DAY_OF_WEEK
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 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
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
| Constructor Detail |
|---|
protected Calendar()
| Method Detail |
|---|
public boolean after(Object when)
public boolean before(Object when)
protected abstract void computeFields()
protected abstract void computeTime()
public boolean equals(Object obj)
equals in class Objectobj - the reference object with which to compare.
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 setTime(Date date)
protected void setTimeInMillis(long millis)
public void setTimeZone(TimeZone value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||