@NotThreadSafe public class Stopwatch extends Object
| Modifier and Type | Field and Description |
|---|---|
private long |
elapsedTime
Time that elapsed while the stopwatch was running.
|
private Long |
startTime
Time the stopwatch was started.
|
private Long |
stopTime
Time the stopwatch was stopped.
|
| Constructor and Description |
|---|
Stopwatch()
Constructor.
|
Stopwatch(long startTimeInMillis)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
elapsedTime()
Time, in milliseconds, that elapsed while the stopwatch was running.
|
long |
elapsedTime(TimeUnit unit)
Time, in the given time unit, that elapsed while the stopwatch was running.
|
boolean |
isRunning()
Checks if the stopwatch is currently running.
|
void |
reset()
Reset the stopwatch such that it is not running and no time has elapsed.
|
void |
start()
Starts the stopwatch if it hasn't been started since being constructed or
reset() was called. |
void |
stop()
Stops the stopwatch if it hasn't been stopped since being constructed or
reset() was called. |
private Long startTime
private Long stopTime
private long elapsedTime
public Stopwatch()
public Stopwatch(long startTimeInMillis)
startTimeInMillis - the time, in milliseconds since the epoch, when the stop watch startedpublic long elapsedTime()
public long elapsedTime(@Nonnull TimeUnit unit)
unit - time unit in which the result is returnedpublic boolean isRunning()
public void reset()
public void start()
reset() was called.public void stop()
reset() was called.Copyright © 1999–2014. All rights reserved.