This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Converting a date object from GMT to EST Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting a date object from GMT to EST" Watch "Converting a date object from GMT to EST" New topic

Converting a date object from GMT to EST

Ranch Hand

Joined: Aug 18, 2005
Posts: 372
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?

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
wood burning stoves
subject: Converting a date object from GMT to EST