File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes timestamps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "timestamps" Watch "timestamps" New topic


manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Hiw to find difference between two time stamps?
Is there any direct method , which gives the difference.. what is the easy way to do it.

Nayanjyoti Talukdar
Ranch Hand

Joined: Feb 12, 2002
Posts: 71
I don't think there is any direct method to get the difference between timestamp. You'll have to formulate using GregorianCalendar.
Nayanjyoti Talukdar
Ranch Hand

Joined: Feb 12, 2002
Posts: 71
One more solution....
U can use the class called Timestamp which extends Date class. Date class has methods of comparing two objects.
Hope, this helps u.
K Elangovan

Joined: Jan 17, 2003
Posts: 6
Hi Nayanjyoti Talukdar,
Can you give a small example code?
Thanks in advance.
K. Elangovan.
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The difference as what? The simplest way is to use getTime() to get the timestamps in milliseconds since 1970, which is a long. You can simply subtract the two values to get the difference in milliseconds.
That may or may not be useful to you.
- Peter
I agree. Here's the link:
subject: timestamps
jQuery in Action, 3rd edition