Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 finding time
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Junaid2pac




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: 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);
 }
}
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: