Any suggestion on the best way to track relative time (mm:ss sincesomething happened)? I have the Date object of the begining time andthe current Date object. However, I don't see anyway to get a diff ofthe Date objects (UNIX had a timediff method). I want to display asmm:ss.-Robert
|
|
0
|
|
|
|
Reply
|
N7093v (29)
|
4/6/2007 5:35:08 PM |
|
On Apr 6, 10:35 am, "Robert M. Gary" <N70...@gmail.com> wrote:> Any suggestion on the best way to track relative time (mm:ss since> something happened)? I have the Date object of the begining time and> the current Date object. However, I don't see anyway to get a diff of> the Date objects (UNIX had a timediff method). I want to display as> mm:ss.>> -RobertIf you have a choice, it would probably be better to useSystem.currentTimeMillis()final long before = System.currentTimeMillis();doStuff();final long after = System.currentTimeMillis();final long duration = after - before;However, if you only have access to the Date objects:final Date dateBefore = new Date();doStuff();final Date dateAfter = new Date();final long duration = dateAfter.getTime() - dateBefore.getTime();
|
|
0
|
|
|
|
Reply
|
Daniel
|
4/6/2007 7:19:47 PM
|
|