public final class Timestamps
extends java.lang.Object
protobuf/timestamp.proto. All operations throw an
IllegalArgumentException if the input(s) are not valid.| Modifier and Type | Field and Description |
|---|---|
static Timestamp |
EPOCH
A constant holding the
Timestamp of epoch time, 1970-01-01T00:00:00.000000000Z. |
static Timestamp |
MAX_VALUE
A constant holding the maximum valid
Timestamp, 9999-12-31T23:59:59.999999999Z. |
static Timestamp |
MIN_VALUE
A constant holding the minimum valid
Timestamp, 0001-01-01T00:00:00Z. |
| Modifier and Type | Method and Description |
|---|---|
static Timestamp |
add(Timestamp start,
Duration length)
Add a duration to a timestamp.
|
static Duration |
between(Timestamp from,
Timestamp to)
Calculate the difference between two timestamps.
|
static Timestamp |
checkValid(Timestamp.Builder timestampBuilder)
Builds the given builder and throws an
IllegalArgumentException if it is not valid. |
static Timestamp |
checkValid(Timestamp timestamp)
Throws an
IllegalArgumentException if the given Timestamp is not valid. |
static java.util.Comparator<Timestamp> |
comparator()
Returns a
Comparator for Timestamps which sorts in increasing
chronological order. |
static int |
compare(Timestamp x,
Timestamp y)
Compares two timestamps.
|
static Timestamp |
fromMicros(long microseconds)
Create a Timestamp from the number of microseconds elapsed from the epoch.
|
static Timestamp |
fromMillis(long milliseconds)
Create a Timestamp from the number of milliseconds elapsed from the epoch.
|
static Timestamp |
fromNanos(long nanoseconds)
Create a Timestamp from the number of nanoseconds elapsed from the epoch.
|
static Timestamp |
fromSeconds(long seconds)
Create a Timestamp from the number of seconds elapsed from the epoch.
|
static boolean |
isValid(long seconds,
int nanos)
Returns true if the given number of seconds and nanos is a valid
Timestamp. |
static boolean |
isValid(Timestamp timestamp)
Returns true if the given
Timestamp is valid. |
static Timestamp |
parse(java.lang.String value)
Parse from RFC 3339 date string to Timestamp.
|
static Timestamp |
subtract(Timestamp start,
Duration length)
Subtract a duration from a timestamp.
|
static long |
toMicros(Timestamp timestamp)
Convert a Timestamp to the number of microseconds elapsed from the epoch.
|
static long |
toMillis(Timestamp timestamp)
Convert a Timestamp to the number of milliseconds elapsed from the epoch.
|
static long |
toNanos(Timestamp timestamp)
Convert a Timestamp to the number of nanoseconds elapsed from the epoch.
|
static long |
toSeconds(Timestamp timestamp)
Convert a Timestamp to the number of seconds elapsed from the epoch.
|
static java.lang.String |
toString(Timestamp timestamp)
Convert Timestamp to RFC 3339 date string format.
|
public static final Timestamp MIN_VALUE
Timestamp, 0001-01-01T00:00:00Z.public static final Timestamp MAX_VALUE
Timestamp, 9999-12-31T23:59:59.999999999Z.public static java.util.Comparator<Timestamp> comparator()