Interface ClockSource
-
- All Known Implementing Classes:
ClockSource.MillisecondClockSource,ClockSource.NanosecondClockSource
public interface ClockSourceA resolution-independent provider of current time-stamps and elapsed time calculations.- Author:
- Brett Wooldridge
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classClockSource.FactoryFactory class used to create a platform-specific ClockSource.static classClockSource.MillisecondClockSourcestatic classClockSource.NanosecondClockSource
-
Field Summary
Fields Modifier and Type Field Description static ClockSourceCLOCKstatic String[]TIMEUNIT_DISPLAY_VALUESstatic TimeUnit[]TIMEUNITS_DESCENDING
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static longcurrentTime()Get the current time-stamp (resolution is opaque).longcurrentTime0()static StringelapsedDisplayString(long startTime, long endTime)Get a String representation of the elapsed time in appropriate magnitude terminology.default StringelapsedDisplayString0(long startTime, long endTime)static longelapsedMillis(long startTime)Convert an opaque time-stamp returned by currentTime() into an elapsed time in milliseconds, based on the current instant in time.static longelapsedMillis(long startTime, long endTime)Get the difference in milliseconds between two opaque time-stamps returned by currentTime().longelapsedMillis0(long startTime)longelapsedMillis0(long startTime, long endTime)static longelapsedNanos(long startTime)Convert an opaque time-stamp returned by currentTime() into an elapsed time in milliseconds, based on the current instant in time.static longelapsedNanos(long startTime, long endTime)Get the difference in nanoseconds between two opaque time-stamps returned by currentTime().longelapsedNanos0(long startTime)longelapsedNanos0(long startTime, long endTime)static TimeUnitgetSourceTimeUnit()Get the TimeUnit the ClockSource is denominated in.TimeUnitgetSourceTimeUnit0()static longplusMillis(long time, long millis)Return the specified opaque time-stamp plus the specified number of milliseconds.longplusMillis0(long time, long millis)static longtoMillis(long time)Convert an opaque time-stamp returned by currentTime() into milliseconds.longtoMillis0(long time)static longtoNanos(long time)Convert an opaque time-stamp returned by currentTime() into nanoseconds.longtoNanos0(long time)
-
-
-
Field Detail
-
CLOCK
static final ClockSource CLOCK
-
TIMEUNITS_DESCENDING
static final TimeUnit[] TIMEUNITS_DESCENDING
-
TIMEUNIT_DISPLAY_VALUES
static final String[] TIMEUNIT_DISPLAY_VALUES
-
-
Method Detail
-
currentTime
static long currentTime()
Get the current time-stamp (resolution is opaque).- Returns:
- the current time-stamp
-
currentTime0
long currentTime0()
-
toMillis
static long toMillis(long time)
Convert an opaque time-stamp returned by currentTime() into milliseconds.- Parameters:
time- an opaque time-stamp returned by an instance of this class- Returns:
- the time-stamp in milliseconds
-
toMillis0
long toMillis0(long time)
-
toNanos
static long toNanos(long time)
Convert an opaque time-stamp returned by currentTime() into nanoseconds.- Parameters:
time- an opaque time-stamp returned by an instance of this class- Returns:
- the time-stamp in nanoseconds
-
toNanos0
long toNanos0(long time)
-
elapsedMillis
static long elapsedMillis(long startTime)
Convert an opaque time-stamp returned by currentTime() into an elapsed time in milliseconds, based on the current instant in time.- Parameters:
startTime- an opaque time-stamp returned by an instance of this class- Returns:
- the elapsed time between startTime and now in milliseconds
-
elapsedMillis0
long elapsedMillis0(long startTime)
-
elapsedMillis
static long elapsedMillis(long startTime, long endTime)Get the difference in milliseconds between two opaque time-stamps returned by currentTime().- Parameters:
startTime- an opaque time-stamp returned by an instance of this classendTime- an opaque time-stamp returned by an instance of this class- Returns:
- the elapsed time between startTime and endTime in milliseconds
-
elapsedMillis0
long elapsedMillis0(long startTime, long endTime)
-
elapsedNanos
static long elapsedNanos(long startTime)
Convert an opaque time-stamp returned by currentTime() into an elapsed time in milliseconds, based on the current instant in time.- Parameters:
startTime- an opaque time-stamp returned by an instance of this class- Returns:
- the elapsed time between startTime and now in milliseconds
-
elapsedNanos0
long elapsedNanos0(long startTime)
-
elapsedNanos
static long elapsedNanos(long startTime, long endTime)Get the difference in nanoseconds between two opaque time-stamps returned by currentTime().- Parameters:
startTime- an opaque time-stamp returned by an instance of this classendTime- an opaque time-stamp returned by an instance of this class- Returns:
- the elapsed time between startTime and endTime in nanoseconds
-
elapsedNanos0
long elapsedNanos0(long startTime, long endTime)
-
plusMillis
static long plusMillis(long time, long millis)Return the specified opaque time-stamp plus the specified number of milliseconds.- Parameters:
time- an opaque time-stampmillis- milliseconds to add- Returns:
- a new opaque time-stamp
-
plusMillis0
long plusMillis0(long time, long millis)
-
getSourceTimeUnit
static TimeUnit getSourceTimeUnit()
Get the TimeUnit the ClockSource is denominated in.- Returns:
- the TimeUnit the ClockSource is denominated in.
-
getSourceTimeUnit0
TimeUnit getSourceTimeUnit0()
-
elapsedDisplayString
static String elapsedDisplayString(long startTime, long endTime)
Get a String representation of the elapsed time in appropriate magnitude terminology.- Parameters:
startTime- an opaque time-stampendTime- an opaque time-stamp- Returns:
- a string representation of the elapsed time interval
-
elapsedDisplayString0
default String elapsedDisplayString0(long startTime, long endTime)
-
-