im in bad need of help! i am implementing a sorting program and i need the code for the timer.. please help me.. what can i do? when i press start the sorting the timer needs to start and stop when the list has been sorted.. how will i do it? i need to have it in nanoseconds..
10-20-2004, 06:11 AM
don't know about nano seconds but in case of milisecond, I would just use the following:
This shoulod give you the current time in miliseconds (I think that's as acurate as it gets in Java tbh)
when you get the time before and after running the sort, you can then just substract to get the duration
10-20-2004, 07:31 AM
I already tried that. the problem is that my program is ..sorting.. and sorts in a split of a second.. when i used system.currentTimeMillis() it only gives me 0.. because it cannot capture the system time.
10-20-2004, 09:52 PM
i'm not aware of being able to get time in nanoseconds.
10-20-2004, 10:28 PM
wouldnt you just multiply the milliseconds you have by 1000 or whatever?
10-20-2004, 10:44 PM
that would display it as nanoseconds, but wouldn't actually have the precision.