• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing TimeZone of Date.

 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to convert my Date timezone from local setting to say Zulu.

First of all Date class does not support setting of TimeZone [method is depricated.]

I have found a way to change the timeZone, but I am not very sure if its the best way to change the TimeZone.

Following is the code which currently works fine.


I am not comfortable with the idea of first getting String and then actually getting the changed date.

Is there any better way to change the TimeZone ???

Thanks in advance.

This following program is my test program, in case if one wants to run the code.

 
R K Singh
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
still wondering, I doubt that its the best way to change the timezone?

I think, its not necessary to first convert to String and then get the changed timeZone.
I will really appreciate if someone has used or know any other alternate way to change the timezone.

Thanks in advance.
reply
    Bookmark Topic Watch Topic
  • New Topic