Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

timestamps

 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
thanks
ram
 
Nayanjyoti Talukdar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I don't think there is any direct method to get the difference between timestamp. You'll have to formulate using GregorianCalendar.
-----------
Nayan.
 
Nayanjyoti Talukdar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
------------
Nayan
 
K Elangovan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nayanjyoti Talukdar,
Can you give a small example code?
Thanks in advance.
K. Elangovan.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic