• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get the time diffrence

 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am entering time.

But how can i get the time difference between two times.

Eg if enter 05:00 and 19:00

then how can i get the difference between them.

Please help me.

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20661
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using java.text.DateFormat and java.util.Date. Using the first, convert the strings to Date objects. Then subtract the two Dates, using their getTime() methods.

This will only work of course if the Dates will be on the same actual date. Also, because of daylight savings time, the results may be a little different than you think.
 
Daniel Jurado
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Try reading about Calendar class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic