wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes calculate time difference b/w two time entry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "calculate time difference b/w two time entry" Watch "calculate time difference b/w two time entry" New topic
Author

calculate time difference b/w two time entry

Shweta Chakraborty
Greenhorn

Joined: Sep 04, 2011
Posts: 2
hello
Sir

Please help me I m developing screen for login where I mentioned to give login time in AM and PM.I m using spinner to enter time and calculating the time but there is some problem.
I m using simpleDateFormat class constructor("HH:mm:ss") but not getting d difference.

Please help me to get time difference b/w two time inputs like 10.05AM and 8.05PM.


cheers,
Shweta Chakraborty
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10246
    
    8

Welcome to the Ranch.

In pseudo code
1) Obtain the Date object for the two time inputs (Check the Simple/DateFormat class for methods which will parse the string format and provide you a date object)
2) Obtain the time long value
3) Compute timeValue1-timeValue2 to obtain the difference. Result will indicate long milliseconds
4) Divide result to obtain seconds,minutes,hours

Hint:
Milliseconds=1000 seconds
60 seconds=minute
60 minutes= hour


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
You might be able to use the TimeUnit enum to help with the difference between hours and seconds.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calculate time difference b/w two time entry