Win a copy of The Java Performance Companion this week in the Performance 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
Pie
Posts: 15369
40
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