public final class Timestamp extends Object implements Comparable<Timestamp>
System.nanoTime() as timestamps.
This class takes care the possibility of numerical overflow.
This is a value-based class.| Modifier and Type | Method and Description |
|---|---|
Timestamp |
addTime(TimeDuration t) |
Timestamp |
addTimeMs(long milliseconds) |
int |
compareTo(Timestamp that)
Compare two timestamps, t0 (this) and t1 (that).
|
static Timestamp |
currentTime() |
static long |
currentTimeNanos() |
TimeDuration |
elapsedTime() |
long |
elapsedTimeMs() |
boolean |
equals(Object obj) |
int |
hashCode() |
static Timestamp |
latest(Timestamp a,
Timestamp b) |
String |
toString() |
static Timestamp |
valueOf(long nanos) |
public static long currentTimeNanos()
public Timestamp addTimeMs(long milliseconds)
milliseconds - the time period to be added.Timestamp whose value is calculated
by adding the given milliseconds to this timestamp.public Timestamp addTime(TimeDuration t)
t - the time period to be added.Timestamp whose value is calculated
by adding the given milliseconds to this timestamp.public long elapsedTimeMs()
public TimeDuration elapsedTime()
public int compareTo(Timestamp that)
t0 - t1 < 0, not t0 < t1,
in order to take care the possibility of numerical overflow.compareTo in interface Comparable<Timestamp>System.nanoTime()Copyright © 2017–2022 The Apache Software Foundation. All rights reserved.