Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting a date object from GMT to EST

 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a couple of requirements

1. I have a Date object that represents the date and time in GMT. I need to be able to convert this into a date object that represents the equivalent EST time, Daylight savings need to be taken into account

2. I also need to convert a Date object representing the EST time into a Date object that represents the corresponding GMT time again taking into account Daylight savings.

I cannot rely on a constant difference between GMT and EST because daylight saving happens only in EST. I have tried out using the TimeZone, DateFormat and Calendar APIs, but I have not been successful.

Can someone help me with the code for doing this?

Thanks.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A java.util.Date always represents a time in UT/GMT (they're the same, to all practical purposes) internally. But a java.util.Date is not the way to exchange date/time information with a user or another system (unless it uses UT). Look at Calendar, TimeZone and DateFormat for that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic