public class DefaultTimeService extends Object implements TimeService
TimeService
. It does not perform any optimization and relies on System.currentTimeMillis()
and System.nanoTime()
.Constructor and Description |
---|
DefaultTimeService() |
Modifier and Type | Method and Description |
---|---|
long |
expectedEndTime(long duration,
TimeUnit inputTimeUnit) |
boolean |
isTimeExpired(long endTime) |
long |
remainingTime(long endTime,
TimeUnit outputTimeUnit) |
long |
time() |
long |
timeDuration(long startTime,
long endTime,
TimeUnit outputTimeUnit) |
long |
timeDuration(long startTime,
TimeUnit outputTimeUnit)
It is equivalent to
timeDuration(startTime, time(), outputTimeUnit) . |
long |
wallClockTime() |
public long wallClockTime()
wallClockTime
in interface TimeService
public long time()
time
in interface TimeService
public long timeDuration(long startTime, TimeUnit outputTimeUnit)
TimeService
timeDuration(startTime, time(), outputTimeUnit)
.timeDuration
in interface TimeService
startTime
- start cpu time in nanoseconds, usually returned by TimeService.time()
.outputTimeUnit
- the TimeUnit
of the returned value.public long timeDuration(long startTime, long endTime, TimeUnit outputTimeUnit)
timeDuration
in interface TimeService
startTime
- start cpu time in nanoseconds, usually returned by TimeService.time()
.endTime
- end cpu time in nanoseconds, usually returned by TimeService.time()
.outputTimeUnit
- the TimeUnit
of the returned value.public boolean isTimeExpired(long endTime)
isTimeExpired
in interface TimeService
endTime
- a cpu time in nanoseconds, usually returned by TimeService.time()
true
if the endTime is less or equals than the current cpu time.public long remainingTime(long endTime, TimeUnit outputTimeUnit)
remainingTime
in interface TimeService
endTime
- the end cpu time in nanoseconds.outputTimeUnit
- the TimeUnit
of the returned value.public long expectedEndTime(long duration, TimeUnit inputTimeUnit)
expectedEndTime
in interface TimeService
duration
- the duration.inputTimeUnit
- the TimeUnit
of the duration.TimeService.time()
).Copyright © 2014 JBoss, a division of Red Hat. All Rights Reserved.