TimeSpan
A period of elapsed time. Each TimeSpan represents a period of time, in milliseconds, greater than or equal to 0. It can be created by specifying a start and stop time, or a start time and an elapsed duration.
Fields
ZERO
A static TimeSpan representing a duration of 0 milliseconds.
startTimeMs
The start time of the TimeSpan in milliseconds.
stopTimeMs
The stop time of the TimeSpan in milliseconds.
totalTimeMs
The total duration of the TimeSpan in milliseconds (stopTimeMs - startTimeMs).
Methods
TimeSpan(double startTimeMs, double stopTimeMs)
Constructs a new TimeSpan. The totalTimeMs (calculated as stopTimeMs - startTimeMs) must be greater than or equal to 0. Throws an IllegalArgumentException if the duration is negative.
TimeSpan(TimeSpan timeSpan)
Constructs a new TimeSpan by copying an existing TimeSpan.
elapsed(double startTimeMs, double elapsedTimeMs)
Static factory method. Creates a new TimeSpan based on a startTimeMs and an elapsedTimeMs.
getStartTimeMs()
Returns the start time of the TimeSpan in milliseconds.
getStopTimeMs()
Returns the stop time of the TimeSpan in milliseconds.
getTotalTimeMs()
Returns the total amount of time represented by this TimeSpan, in milliseconds.
add(double timeToAddMs)
Returns a new TimeSpan by adding timeToAddMs to the stopTimeMs of the current TimeSpan.
add(TimeSpan timeToAdd)
Returns a new TimeSpan by adding the totalTimeMs of the timeToAdd TimeSpan to the stopTimeMs of the current TimeSpan.
hashCode()
Returns a hash code for the TimeSpan.
equals(Object obj)
Compares this TimeSpan to another object for equality. Two TimeSpan objects are considered equal if their startTimeMs and stopTimeMs are equal within a small tolerance.
toString()
Returns a string representation of the TimeSpan in the format "totalTimeMsms".