Reputation: 135
There is a lot of similar topics but I couldn't find something similar then my problem. I've found only how to calculate if for example second time is greater then first time, like:
The result is easy to get. Just subtract second time with first using Date API. Difference is in milliseconds and you can easily convert them in seconds/minutes..
What I want to know, how to get difference between time in first day and time in second day, for example:
Difference should be 8 hours and 5 minutes.
Or another example
Difference should be 5 hours.
How to calculate time in this way? Any help is appreciated.
Upvotes: 1
Views: 1198
Reputation: 21657
Use Calendar class. Set your day, hour and minutes and finally subtract those dates (in milliseconds) and you will convert result in hour, minutes and seconds.
Upvotes: 0
Reputation: 3506
Convert your date and time to TimeStamp (It's just the long representation of a date in milliseconds since Jan. 1, 1970.), then calculate difference, and transferred from milliseconds to hours.
Also check this
Upvotes: 1