This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Timestamp in GMT and the difference

 
Geetha Gubendran
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to generate current timestamp in GMT and also find the difference between this current timestamp and the timestamp (GMT) I pick it up from database. Can somebody help me out on how can I generate the GMT timestamp and how am I going to find the difference between timestamps in minutes. Thanks.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15644
47
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method System.currentTimeMillis() returns the number of milliseconds that have elapsed since January 1, 1970, 12:00 AM UTC.

Getting the difference in minutes between two timestamps is very simple: just subtract the two millisecond values. Divide by 60,000 to get the difference in minutes (one minute is 60 seconds, one second is 1,000 milliseconds).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic