This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GMT to EDT  RSS feed

 
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



 
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JavaDatesFaq has some hints on how to work with timezones.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!