• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert time zones

 
yuvaraja ram
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like to know how we can convert the Time zone from EST to EDT with the time being saved for the dayLight changes.
 
Joni Salonen
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't convert; you format. Here's an example:


[ February 20, 2006: Message edited by: Joni Salonen ]
 
Paul Clapham
Sheriff
Pie
Posts: 20164
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you mean "Eastern Standard Time" and "Eastern Daylight Time" then they are the same time zone and no conversion is necessary. It doesn't make sense to ask for a time to be formatted as if it were daylight saving time, if it isn't.
 
yuvaraja ram
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I had tried like what you had described but it is displaying GMT as its time zone when we set the TimeZone in the code "df.setTimeZone(TimeZone.getTimeZone("EDT"));" My requirement is to display the time zone as EDT always without any loss of time.
 
Joni Salonen
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getTimeZone returns UTC when the parameter you pass to it is not the name of a time zone. What exactly is "EDT"? Does it have daylight savings time?

You could check out the SimpleTimeZone class; with it you can create a TimeZone object with any offset and daylight savings time rules you want.

http://java.sun.com/j2se/1.5.0/docs/api/java/util/SimpleTimeZone.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic