Computer Science Canada

finding time

Author:  Junaid2pac [ Tue Jan 22, 2008 10:00 pm ]
Post subject:  finding time

im wondering how i can use a timer in java. is there any timer built in java, if not how would i make my own. For ex start counting time if something happens and then stop when something else happens.

Author:  HeavenAgain [ Tue Jan 22, 2008 10:08 pm ]
Post subject:  RE:finding time

you do not want to make anything thats already made... look in the api, im sure theres a timer class, but heres a quick sample you can use
code:
class Test
{
 public static void main(String[] args)
 {
   long startTime = System.currentTimeMillis();
// do something   
   long endTime = System.currentTimeMillis();
   System.out.println(endTime-startTime);
 }
}


: