0

Hi,

Is there a way of timing how long it takes between a piece of code executing to when it finishes and then displaying this time? I would like to display a clock which begins timing when a program starts running and stops when it finishes.

Thanks

5
Contributors
8
Replies
9
Views
12 Years
Discussion Span
Last Post by Aldehyde81
0

just add a timer at the start of the program execution .... there are two types of timers .... one for gui and one is general
general:
java.util.Timer
Timer t = new Timer();

gui:
javax.swing.*
Timer t = new Timer(ActionListener, delay);

Read more about the timers in the java API.

0

What you see is in milliseconds. When you get the difference, multiply by 1000 and you will have how many seconds have passed

0

You have a value in milliseconds. You can either use SimpleDateFormat, or do it yourself using the following rules:
1 sec = 1000 millisec
1 min = 60 sec
1 hour = 60 min

And sorry about my last post, I made a very big mistake: You must divide by 1000 to get the seconds

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.