public class Stopwatch
extends java.lang.Object
Constructor and Description |
---|
Stopwatch()
Initializes a new instance of the
Stopwatch class. |
Modifier and Type | Method and Description |
---|---|
java.time.Duration |
getElapsed()
Gets the total elapsed time measured by the current instance.
|
static long |
getTimestamp()
Gets the current timestamp with the highest precision available.
|
boolean |
isRunning()
Gets a value indicating whether the
Stopwatch timer is running. |
void |
reset()
Stops time interval measurement and resets the elapsed time to zero.
|
void |
restart()
Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed
time.
|
void |
start()
Starts, or resumes, measuring elapsed time for an interval.
|
static Stopwatch |
startNew()
Initializes a new
Stopwatch instance, sets the elapsed time property to zero, and
starts measuring elapsed time. |
void |
stop()
Stops measuring elapsed time for an interval.
|
public Stopwatch()
Stopwatch
class.public void start()
public static Stopwatch startNew()
Stopwatch
instance, sets the elapsed time property to zero, and
starts measuring elapsed time.Stopwatch
that has just begun measuring elapsed timepublic void stop()
public void reset()
public void restart()
public boolean isRunning()
Stopwatch
timer is running.true
if the Stopwatch
instance is currently running and measuring
elapsed time for an interval; otherwise, false
public java.time.Duration getElapsed()
Duration
representing the total elapsed time measured by the current instancepublic static long getTimestamp()