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) |
Instant |
instant() |
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 TimeServicepublic long time()
time in interface TimeServicepublic Instant instant()
instant in interface TimeServiceInstant. Similarly to TimeService.time(), note that some platforms do not provide nanosecond precision.public long timeDuration(long startTime,
TimeUnit outputTimeUnit)
TimeServicetimeDuration(startTime, time(), outputTimeUnit).timeDuration in interface TimeServicestartTime - 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 TimeServicestartTime - 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 TimeServiceendTime - 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 TimeServiceendTime - the end cpu time in nanoseconds.outputTimeUnit - the TimeUnit of the returned value.public long expectedEndTime(long duration,
TimeUnit inputTimeUnit)
expectedEndTime in interface TimeServiceduration - the duration.inputTimeUnit - the TimeUnit of the duration.TimeService.time()).Copyright © 2024 JBoss, a division of Red Hat. All rights reserved.