44 |
|
* @revised $Date$ |
45 |
|
* @editor $Author$ |
46 |
|
* |
47 |
– |
* @fixme The previous version created singleton subclass instances. I could |
48 |
– |
* not see any reason to create subclasses instead of just instances. |
49 |
– |
* Neither approach allows creation of your own units. |
47 |
|
*/ |
48 |
|
public final class TimeUnit implements java.io.Serializable { |
49 |
|
|
50 |
|
/** |
51 |
|
* Return the current value of the system high resolution timer, in |
52 |
< |
* nanoseconds. This method can only be used to measure elapsed time |
52 |
> |
* nanoseconds. |
53 |
> |
* <p>This method can only be used to measure elapsed time |
54 |
|
* and is not related to any notion of system, or wall-clock time. |
55 |
|
* Although the value returned represents nanoseconds since some |
56 |
|
* arbitrary start time in the past, the resolution at which this value |
57 |
< |
* is updated is not specified. It provides have nanosecond precision, but |
57 |
> |
* is updated is not specified. It provides nanosecond precision, but |
58 |
|
* not necessarily nanosecond accuracy. |
59 |
< |
* It is guaranteed that successive return |
59 |
> |
* <p>It is guaranteed that successive return |
60 |
|
* values from this method will not decrease. |
61 |
|
* |
62 |
< |
* <p> For example to measure how long some code takes to execute, |
62 |
> |
* <p> For example, to measure how long some code takes to execute, |
63 |
|
* with nanosecond precision: |
64 |
|
* <pre> |
65 |
< |
* long startTime = TimeUnit.nanoTime(); |
66 |
< |
* // ... the code being measured ... |
67 |
< |
* long estimatedTime = TimeUnit.nanoTime() - startTime; |
65 |
> |
* long startTime = TimeUnit.nanoTime(); |
66 |
> |
* // ... the code being measured ... |
67 |
> |
* long estimatedTime = TimeUnit.nanoTime() - startTime; |
68 |
|
* </pre> |
69 |
|
* |
70 |
|
* @return The current value of the system high resolution timer, in |
97 |
|
} |
98 |
|
|
99 |
|
/** |
100 |
< |
* Equivalent to <code>NANOOSECONDS.convert(duration, this)</code>. |
100 |
> |
* Equivalent to <code>NANOSECONDS.convert(duration, this)</code>. |
101 |
|
* @param duration the duration |
102 |
|
* @return the converted duration. |
103 |
|
**/ |