• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Set TimeZone (to PST)

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
brevity is the soul of wit - shakepeare. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic