TimeZone
Another
time-related class is TimeZone. The
abstract TimeZone class allows you
to work with time zone offsets from Greenwich mean time (GMT), also referred to
as Coordinated Universal Time (UTC). It also computes daylight saving time. TimeZone only supplies the default
constructor.
A
sampling of methods defined by TimeZone
is given in Table 19-6.
SimpleTimeZone
The SimpleTimeZone class is a convenient
subclass of TimeZone. It implements TimeZone's abstract methods and allows
you to work with time zones for a Gregorian
calendar. It also computes daylight saving time.
SimpleTimeZone defines four constructors.
One is SimpleTimeZone(int timeDelta, String tzName)
This
constructor creates a SimpleTimeZone
object. The offset relative to Greenwich mean time (GMT) is timeDelta. The time zone is named tzName.
The
second SimpleTimeZone constructor is
SimpleTimeZone(int
timeDelta, String tzId, int dstMonth0, int dstDayInMonth0,
int dstDay0, int time0,
int dstMonth1, int dstDayInMonth1, int dstDay1,
int time1)
Here,
the offset relative to GMT is specified in timeDelta.
The time zone name is passed in tzId.
The start of daylight saving time is indicated by the parameters dstMonth0, dstDayInMonth0, dstDay0,
and time0. The end of daylight saving
time is indicated by the parameters
dstMonth1, dstDayInMonth1, dstDay1, and time1.
The
third SimpleTimeZone constructor is
SimpleTimeZone(int
timeDelta, String tzId, int dstMonth0, int dstDayInMonth0,
int dstDay0, int time0, int dstMonth1, int
dstDayInMonth1,
int dstDay1, int time1, int dstDelta)
Here, dstDelta is the number of milliseconds
saved during daylight saving time. The fourth SimpleTimeZone constructor is:
SimpleTimeZone(int
timeDelta, String tzId, int dstMonth0, int dstDayInMonth0,
int dstDay0, int time0,
int time0mode, int dstMonth1, int dstDayInMonth1,
int dstDay1, int time1, int time1mode, int
dstDelta)
Here, time0mode specifies the mode of the
starting time, and time1mode
specifies the mode of the ending time. Valid mode values include:
The time
mode indicates how the time values are interpreted. The default mode used by
the other constructors is WALL_TIME.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.