@Immutable public final class Timestamp extends Object
Use TimestampFactory.now() to get the current timestamp since epoch
(1970-01-01T00:00:00Z).
| Modifier and Type | Method and Description |
|---|---|
Timestamp |
addNanos(long nanos)
Returns a
Timestamp calculated as this Timestamp plus some number of
nanoseconds. |
static Timestamp |
create(long seconds,
int nanos)
Creates a new timestamp from given seconds and nanoseconds.
|
boolean |
equals(Object obj) |
static Timestamp |
fromMillis(long millis)
Creates a new timestamp from the given milliseconds.
|
int |
getNanos()
Returns the number of nanoseconds after the number of seconds since the Unix Epoch represented
by this timestamp.
|
long |
getSeconds()
Returns the number of seconds since the Unix Epoch represented by this timestamp.
|
int |
hashCode() |
String |
toString() |
public static Timestamp create(long seconds, int nanos)
seconds - Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
be from from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.nanos - Non-negative fractions of a second at nanosecond resolution. Negative
second values with fractions must still have non-negative nanos values that count forward
in time. Must be from 0 to 999,999,999 inclusive.Timestamp with specified fields. For invalid inputs, a Timestamp
of zero is returned.public static Timestamp fromMillis(long millis)
public long getSeconds()
public int getNanos()
public Timestamp addNanos(long nanos)
Timestamp calculated as this Timestamp plus some number of
nanoseconds.nanos - the nanoseconds to be added to the current timestamp.Timestamp calculated as this Timestamp plus some number of
nanoseconds.