aspose file tools*
The moose likes Java in General and the fly likes GMT to EDT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "GMT to EDT" Watch "GMT to EDT" New topic
Author

GMT to EDT

Anjali S Sharma
Ranch Hand

Joined: Jun 29, 2005
Posts: 279
In my Java code, I am getting Time in GMT

Date recDateObj = getGMTDate();

Can you please let me know how I can convert this time to one in EDT time zone.



James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Anjali S Sharma wrote:In my Java code, I am getting Time in GMT

Date recDateObj = getGMTDate();

Can you please let me know how I can convert this time to one in EDT time zone.





java.util.Date object have no explicit time zone. They have an implicit time zone of UTC since they hold only the number of milliseconds since 1/1/1970 UTC (the epoch). All date helper classes such as SimpleDateFormat assume this epoch and calculate accordingly..

If you need a String representation of the date then you should use SimpleDateFormat and initialise it with the desired time zone.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
The JavaDatesFaq has some hints on how to work with timezones.


Ping & DNS - my free Android networking tools app
 
Don't get me started about those stupid light bulbs.
 
subject: GMT to EDT