wood burning stoves 2.0*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 14118
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Timestamp in GMT and the difference