basically i have one time
currentTime = DateFormat.getTimeInstance().format(new Date());
and i want to calculate how much time has past since currentTime. any ideas?
How many hours are between 9:00 and 17:00? There are 8 hours between 9:00 and 17:00. To calculate how many hours are between two times, you should subtract a start time from the end time.
Your currentTime as above will be a String, so difficult to work with.
If you use a Date object instead:
Date interestingDate = new Date();
then you can find the different in milliseconds between the actual current date and interestingDate by doing:
(new Date()).getTime() - interestingDate.getTime()
Also check out the Time class which you could use instead of the Date class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With