| Author |
Timezone - PST and PDT
|
pendse anagha
Ranch Hand
Joined: Mar 09, 2005
Posts: 44
|
|
Hello , I am trying to write business logic based on PST and PDT The code runs on a server - whose timezone is changed appropriately as required between : PST & PDT ( As of today it has been changed to PST ) I am trying to figure out when its PST and when its PDT through code. I am using this code : However - this code always specifies that the Timezone is PDT i.e above method returns TRUE even though I can see that the server is specifying PST So I am now using this : This code works fine . What is wrong with the code which uses the Timezone class ? Thanks in advance , -anagha
|
 |
Ritesh Agrawal
Ranch Hand
Joined: Jan 08, 2004
Posts: 74
|
|
Hi, First of all, using getTimezoneOffset() method of java.util.Date object is not advisable as it is a deprecated method. I am not sure why using TimeZone.getDefault().useDaylightTime() is not working as desired. I have tried sample code in Windows XP machine and tested by changing the date/time settings. For me it worked as desired. The Java API docs for java.util.TimeZone getDefault() says Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation Could you please let us know what implementation you are using. I am using Win XP and J2SE 1.5.
|
Ritesh<br /> <br />SCJP 1.4<br />IBM Test 340<br />IBM AIX V4.0 Certified Professional<br /> <br />Right actions for the future are the best apologies for wrong ones in the past.<br />- Tyron Edwards
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
From the API documentation for TimeZone, method useDaylightTime(): "Queries if this time zone uses daylight savings time." Well, Pacific Time does use daylight saving time. So it will always return you true. If you want to know whether a particular date is in daylight saving time in that time zone then you should use the inDaylightTime(Date) method: "Queries if the given date is in daylight savings time in this time zone."
|
 |
pendse anagha
Ranch Hand
Joined: Mar 09, 2005
Posts: 44
|
|
Thanks Ritesh and Paul , I will check out your suggestions . Regards , -anagha
|
 |
 |
|
|
subject: Timezone - PST and PDT
|
|
|