1public class Chrono {
2
3 private boolean running;
4 private long startTime;
5
6 public Chrono(){
7 running = false;
8 }
9
10 public void start(){
11 running = true;
12 startTime = System.currentTimeMillis();
13 }
14
15 public void stop(){
16 startTime = getTime();
17 running = false;
18 }
19
20 public long getTime(){
21 if (running){
22 return System.currentTimeMillis() - startTime;
23 } else {
24 return startTime;
25 }
26 }
27}