• 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

convert date object in any time zone to GMT or remove time zone

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

I have a date object , this can be associated with any time zone. How do I convert this date object into a date object which has time zone GMT. The input and output object should be date object. Please do not convert and return a string object. thats not I wanted. I wanted a date object with gmt time zone or remove the time zone portion.

Can anybody help me out to resolve this issue or give me a better solution? I have gone through many websites and forums, evryone gives hlf-cooked answers or wrong answers.

Thanks,
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

prince davies wrote:
I have a date object , this can be associated with any time zone. How do I convert this date object into a date object which has time zone GMT. The input and output object should be date object.



Date objects don't have a TZ. They just represent an instant in time, and that instant is the same instant no matter what TZ you happen to be in.

Please do not convert and return a string object. thats not I wanted. I wanted a date object with gmt time zone or remove the time zone portion.



Since Dates don't have a TZ, and since TZ is purely a display issue, using a DateFormat to generate a String is the correct answer. If that doesn't meet your needs, then either you don't understand how Java's date/time classes work, and you need to study up, or else you need to explain what you're actually trying to accomplish and why this approach doesn't meet your needs.

You may also consider looking into Joda Time. It has features that Java's core date/time classes lack.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic