Static Public Member Functions | |
static Timestamp | add (Timestamp start, Duration length) |
static Duration | between (Timestamp from, Timestamp to) |
static Timestamp | checkValid (Timestamp timestamp) |
static Timestamp | checkValid (Timestamp.Builder timestampBuilder) |
static Comparator< Timestamp > | comparator () |
static int | compare (Timestamp x, Timestamp y) |
static Timestamp | fromMicros (long microseconds) |
static Timestamp | fromMillis (long milliseconds) |
static Timestamp | fromNanos (long nanoseconds) |
static Timestamp | fromSeconds (long seconds) |
static boolean | isValid (long seconds, int nanos) |
static boolean | isValid (Timestamp timestamp) |
static Timestamp | parse (String value) throws ParseException |
static Timestamp | subtract (Timestamp start, Duration length) |
static long | toMicros (Timestamp timestamp) |
static long | toMillis (Timestamp timestamp) |
static long | toNanos (Timestamp timestamp) |
static long | toSeconds (Timestamp timestamp) |
static String | toString (Timestamp timestamp) |
Static Public Attributes | |
static final Timestamp | EPOCH = Timestamp.newBuilder().setSeconds(0).setNanos(0).build() |
static final Timestamp | MAX_VALUE |
static final Timestamp | MIN_VALUE |
Private Member Functions | |
Timestamps () | |
Static Private Member Functions | |
static SimpleDateFormat | createTimestampFormat () |
static long | parseTimezoneOffset (String value) throws ParseException |
Static Private Attributes | |
static final Comparator< Timestamp > | COMPARATOR |
static final ThreadLocal< SimpleDateFormat > | timestampFormat |
Utilities to help create/manipulate
. All operations throw an IllegalArgumentException if the input(s) are not {@linkplain isValid(Timestamp) valid}.
Definition at line 54 of file Timestamps.java.
|
inlineprivate |
Definition at line 101 of file Timestamps.java.
|
inlinestatic |
Add a duration to a timestamp.
Definition at line 370 of file Timestamps.java.
|
inlinestatic |
Calculate the difference between two timestamps.
Definition at line 361 of file Timestamps.java.
Throws an IllegalArgumentException if the given Timestamp is not valid.
Definition at line 168 of file Timestamps.java.
|
inlinestatic |
Builds the given builder and throws an IllegalArgumentException if it is not valid. See checkValid(Timestamp).
Definition at line 188 of file Timestamps.java.
|
inlinestatic |
Returns a Comparator for Timestamps which sorts in increasing chronological order. Nulls and invalid Timestamps are not allowed (see isValid).
Definition at line 119 of file Timestamps.java.
|
inlinestaticprivate |
Definition at line 91 of file Timestamps.java.
|
inlinestatic |
Create a Timestamp from the number of microseconds elapsed from the epoch.
Definition at line 325 of file Timestamps.java.
|
inlinestatic |
Create a Timestamp from the number of milliseconds elapsed from the epoch.
Definition at line 303 of file Timestamps.java.
|
inlinestatic |
Create a Timestamp from the number of nanoseconds elapsed from the epoch.
Definition at line 347 of file Timestamps.java.
|
inlinestatic |
Create a Timestamp from the number of seconds elapsed from the epoch.
Definition at line 286 of file Timestamps.java.
|
inlinestatic |
Returns true if the given number of seconds and nanos is a valid Timestamp. The
value must be in the range -62,135,596,800, +253,402,300,799. The
value must be in the range [0, +999,999,999].
Note: Negative second values with fractional seconds must still have non-negative nanos values that count forward in time.
Definition at line 156 of file Timestamps.java.
|
inlinestatic |
Returns true if the given Timestamp is valid. The
value must be in the range -62,135,596,800, +253,402,300,799. The
value must be in the range [0, +999,999,999].
Note: Negative second values with fractional seconds must still have non-negative nanos values that count forward in time.
Definition at line 142 of file Timestamps.java.
|
inlinestatic |
Parse from RFC 3339 date string to Timestamp. This method accepts all outputs of {} and it also accepts any fractional digits (or none) and any offset as long as they fit into nano-seconds precision. Example of accepted format: "1972-01-01T10:00:20.021-05:00"
ParseException | if parsing fails. |
Definition at line 232 of file Timestamps.java.
|
inlinestaticprivate |
Definition at line 402 of file Timestamps.java.
|
inlinestatic |
Subtract a duration from a timestamp.
Definition at line 379 of file Timestamps.java.
|
inlinestatic |
Convert a Timestamp to the number of microseconds elapsed from the epoch.
The result will be rounded down to the nearest microsecond. E.g., if the timestamp represents "1969-12-31T23:59:59.999999999Z", it will be rounded to -1 microsecond.
Definition at line 338 of file Timestamps.java.
|
inlinestatic |
Convert a Timestamp to the number of milliseconds elapsed from the epoch.
The result will be rounded down to the nearest millisecond. E.g., if the timestamp represents "1969-12-31T23:59:59.999999999Z", it will be rounded to -1 millisecond.
Definition at line 316 of file Timestamps.java.
|
inlinestatic |
Convert a Timestamp to the number of nanoseconds elapsed from the epoch.
Definition at line 354 of file Timestamps.java.
|
inlinestatic |
Convert a Timestamp to the number of seconds elapsed from the epoch.
The result will be rounded down to the nearest second. E.g., if the timestamp represents "1969-12-31T23:59:59.999999999Z", it will be rounded to -1 second.
Definition at line 297 of file Timestamps.java.
|
inlinestatic |
Convert Timestamp to RFC 3339 date string format. The output will always be Z-normalized and uses 3, 6 or 9 fractional digits as required to represent the exact value. Note that Timestamp can only represent time from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. See https://www.ietf.org/rfc/rfc3339.txt
Example of generated format: "1972-01-01T10:00:20.021Z"
IllegalArgumentException | if the given timestamp is not in the valid range. |
Definition at line 203 of file Timestamps.java.
|
staticprivate |
Definition at line 103 of file Timestamps.java.
|
static |
A constant holding the Timestamp of epoch time,
.
Definition at line 81 of file Timestamps.java.
|
static |
A constant holding the maximum valid Timestamp,
.
Definition at line 75 of file Timestamps.java.
|
static |
A constant holding the minimum valid Timestamp,
.
Definition at line 69 of file Timestamps.java.
|
staticprivate |
Definition at line 83 of file Timestamps.java.