KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > terracotta > session > util > Timer


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.terracotta.session.util;
5
6 public class Timer {
7   private long start = 0;
8   private long end = 0;
9
10   public Timer() {
11     start();
12   }
13
14   public Timer(boolean doStart) {
15     start = (doStart) ? System.currentTimeMillis() : 0;
16   }
17
18   public void start() {
19     start = System.currentTimeMillis();
20   }
21
22   public void stop() {
23     end = System.currentTimeMillis();
24   }
25
26   public long elapsed() {
27     return end - start;
28   }
29
30   public void reset() {
31     start = end = 0;
32   }
33
34   public long getEnd() {
35     return end;
36   }
37
38   public long getStart() {
39     return start;
40   }
41 }
42
Popular Tags