wood burning stoves
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Timestamp in GMT and the difference" Watch "Timestamp in GMT and the difference" New topic

Timestamp in GMT and the difference

Geetha Gubendran
Ranch Hand

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

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 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: Timestamp in GMT and the difference
jQuery in Action, 3rd edition