This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Timestamp in GMT and the difference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Timestamp in GMT and the difference" Watch "Timestamp in GMT and the difference" New topic
Author

Timestamp in GMT and the difference

Raj Shan
Ranch Hand

Joined: Sep 04, 2006
Posts: 65
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Timestamp in GMT and the difference
 
Similar Threads
Time Stamp values
How to create a date object which contain current date
Current time
TimeStamp - changed by my DB?
Time difference B/W current TimeZone and GMT?