Menu
Topics Index
...
`


More Utility Classes >
Siva Nookala - 15 Apr 2016
In Java by default, there are lot of predefined time zones which correspond to the various countries across the world. Some sample time zones are EST, PDT, GMT etc., These time zones also take into effect the day light savings. In the unlikely event where we want to create our own TimeZone then we can use SimpleTimeZone.

SimpleTimeZone defines four constructors. They are :

SimpleTimeZone(int timeDelta, String tzName)
This creates a SimpleTimeZone with relative offset from Greenwich mean time (GMT). The time zone name is tzName.

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.

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.

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 STANDARD_TIME, WALL_TIME and UTC_TIME. The time mode indicates how the time values are interpreted. The default mode used by the other constructors is WALL_TIME.

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App