| 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: 8434
|
|
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
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
|
You might be able to use the TimeUnit enum to help with the difference between hours and seconds.
|
 |
 |
|
|
subject: calculate time difference b/w two time entry
|
|
|