Java Reference
In-Depth Information
The other versions of the set() method are:
set(int year, int month, int day, int hour, int minute)
set(int year, int month, int day, int hour, int minute, int second)
set(int field, int value)
It's obvious what the first two of these do. In each case the fields not explicitly set will be left at their
original values. The third version of set() sets a field specified by one of the integer constants defined
in the Calendar class for this purpose:
Field
Value
AM _ PM
Can have the values AM or PM , which correspond to values of 0 and
1.
DAY _ OF _ WEEK
Can have the values SUNDAY , MONDAY , etc., through to
SATURDAY , which correspond to values of 1 to 7.
DAY _ OF _ YEAR
Can be set to a value from 1 to 366 .
MONTH
Can be set to a value of JANUARY , FEBRUARY , etc., through to
DECEMBER , corresponding to values of 0 to 11.
DAY _ OF _ MONTH
or DATE
Can be set to a value from 1 to 31.
WEEK _ OF _ MONTH
Can be set to a value from 1 to 6.
WEEK _ OF _ YEAR
Can be set to a value from 1 to 54.
HOUR _ OF _ DAY
A value from 0 to 23.
HOUR
A value from 1 to 12 being the current hour in the am or pm.
MINUTE
The current minute in the current hour - a value from 0 to 59.
SECOND
The second in the current minute, 0 to 59.
MILLISECOND
The millisecond in the current second, 0 to 999.
YEAR
The current year, for example 1998.
ERA
Can be set to either GregorianCalendar.BC or
GregorianCalendar.AD (both values being defined in the
GregorianCalendar class).
ZONE _ OFFSET
A millisecond value indicating the offset from GMT.
DST _ OFFSET
A millisecond value indicating the offset for daylight saving in the
current time zone.
With the exception of AD and BC as noted in the table, the constants for field values are also defined in
the Calendar class. Thus you can set the day of the week with the statement:
Search WWH ::




Custom Search