THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
daylight saving time offset into account. All parameters are interpreted
relative to the calendar for which the particular time zone implementation is
designed. The era parameter represents calendar-specific eras, such as
B.C. and A.D. in the Gregorian calendar.

24.4.3. GregorianCalendar and SimpleTimeZone


The GregorianCalendar class is a concrete subclass of Calendar that reflects UTC (Coordinated
Universal Time), although it cannot always do so exactly. Imprecise behavior is inherited from the time
mechanisms of the underlying system.[2] Parts of a date are specified in UTC standard units and ranges. Here
are the ranges for GregorianCalendar:


[2] Almost all modern systems assume that one day is 24*60*60 seconds. In UTC, about once
a year an extra second, called a leap second, is added to a day to account for the wobble of the
Earth. Most computer clocks are not accurate enough to reflect this distinction, so neither is
the Date class. Some computer standards are defined in GMT, which is the "civil" name for
the standard; UT is the scientific name for the same standard. The distinction between UTC
and UT is that UT is based on an atomic clock and UTC is based on astronomical observations.
For almost all practical purposes, this is an invisibly fine hair to split. See "Further Reading"
on page 755 for references.

YEAR 1292278994


MONTH 011


DATE Day of the month, 131

HOUR_OF_DAY 023

MINUTE 059

SECOND 059

MILLISECOND 0999

The GregorianCalendar class supports several constructors:


publicGregorianCalendar()

Creates a GregorianCalendar object that represents the current time in
the default time zone with the default locale.

publicGregorianCalendar(int year, int month, int date, int
hrs, int min, int sec)

Creates a GregorianCalendar object that represents the given date in
the default time zone with the default locale.

publicGregorianCalendar(int year, int month, int date, int
hrs, int min)

Equivalent to GregorianCalendar(year,month,date,hrs,
min,0) that is, the beginning of the specified minute.
Free download pdf