• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Dates in Java

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm having problems converting GMT date time to other timezone formats. Basically I can convert the date time but it doesnt take into effect the day light saving time. I'm doing something like this.



This code works fine. However It should return GMT+ 11 time in Australian tiem due to day light savings. But it just gives me back GMT+ 10. Any pointers as to how to fix this problem?

Thanks in advance,
Harry
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version (including patch level) of Java are you using?

I noticed on the alldownunder.com Daylight Saving Time page that there was a change for DST in 2008 in Australia. DST will start on the first Sunday in October. In the past, it was apparently the last Sunday in October. We went through a similar change here in the US a year or two ago.

So older versions (i.e. patch levels) of Java will not have the change. You'd have to do some digging through the release notes to see which patches to 1.4.2, 1.5 and 1.6 contain the change.

My curiosity was peeked, so I wrote a quick little program to loop through October. It prints out the GMT time and Sydney time, and the result of TimeZone.inDaylightTime(Date). When I ran the code, I received GMT+11 for the date you had above (22 Oct 2008). (I changed the GMT time to midnight so my tired brain could to the time offset calculation easier ) Notice the DST change occurs as its suppose to on 5 October 2008:



The last date (22 Oct 2008) is the one you showed in your code.

This was run via Java 1.6.0_07. I also ran it against 1.5.0_16 and got the same results. (I didn't run it against a 1.4.2 version, but the latest patch would probably be ok.)

When I ran it against the older Java 1.6.0 and 1.5.0_11, I got very different results:


So those versions are still using the old rule of "last Sunday in October" to calculate when DST starts. Again, you'll need to check the release notes to see at what patch level the new DST rule was introduced for each version.

I hope that helps.
[ August 19, 2008: Message edited by: Mark Vedder ]
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark for your inputs.

Indeed this was the problem. I noticed that may be I will have to apply a patch to make this DST change to happen in Java.
 
reply
    Bookmark Topic Watch Topic
  • New Topic