KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > connextra > util > RealClock


1 package com.connextra.util;
2
3 import java.util.*;
4
5
6 public class RealClock implements Clock {
7     private long myStoppedTime = -1;
8
9     public RealClock() {
10         super();
11     }
12
13     public Date getDate() {
14         return new Date();
15     }
16
17     public long getTime() {
18         if (myStoppedTime != -1) {
19             return myStoppedTime;
20         }
21
22         return System.currentTimeMillis();
23     }
24
25     public void stop() {
26         myStoppedTime = getTime();
27     }
28
29     public String JavaDoc toString() {
30         return String.valueOf(getTime());
31     }
32 }
Popular Tags