• Post Reply Bookmark Topic Watch Topic
  • New Topic

Set TimeZone (to PST)  RSS feed

 
Dee Irun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to convert a Calendar object from one timeZone to another and couldn't succeed. This is what I'm trying to do:



In the above code, the startDate is initially 1/27/06, 5.00 am GMT and I want this to be 1/27/06, 5.00 am PST (since the local time is PST), how ever it is not so. Any idea how to achieve this?

TIA
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the Calendar was set incorrectly to begin with. It seems preferable to fix it when it's created, rather than after it's been passed around to other components of your program. But maybe that's not possible. Well, you should be able to fix this by subtracting the time zone offset. The other thing is you may well need to tell the JVM what time zone to display results in - DateFormat (and SimpleDateFormat) are a good way to control this. Try something like this:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!