6

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?

Simon
  • 451
  • 2
  • 9
  • 19

1 Answers1

17

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.

oli
  • 4,894
  • 1
  • 17
  • 11