@PublicEvolving public final class TimestampData extends Object implements Comparable<TimestampData>
TimestampType
and LocalZonedTimestampType
.
This data structure is immutable and consists of a milliseconds and nanos-of-millisecond since
1970-01-01 00:00:00
. It might be stored in a compact representation (as a long value) if
values are small enough.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TimestampData that) |
boolean |
equals(Object obj) |
static TimestampData |
fromEpochMillis(long milliseconds)
Creates an instance of
TimestampData from milliseconds. |
static TimestampData |
fromEpochMillis(long milliseconds,
int nanosOfMillisecond)
Creates an instance of
TimestampData from milliseconds and a nanos-of-millisecond. |
static TimestampData |
fromInstant(java.time.Instant instant)
Creates an instance of
TimestampData from an instance of Instant . |
static TimestampData |
fromLocalDateTime(java.time.LocalDateTime dateTime)
Creates an instance of
TimestampData from an instance of LocalDateTime . |
static TimestampData |
fromTimestamp(Timestamp timestamp)
Creates an instance of
TimestampData from an instance of Timestamp . |
long |
getMillisecond()
Returns the number of milliseconds since
1970-01-01 00:00:00 . |
int |
getNanoOfMillisecond()
Returns the number of nanoseconds (the nanoseconds within the milliseconds).
|
int |
hashCode() |
static boolean |
isCompact(int precision)
Returns whether the timestamp data is small enough to be stored in a long of milliseconds.
|
java.time.Instant |
toInstant()
Converts this
TimestampData object to a Instant . |
java.time.LocalDateTime |
toLocalDateTime()
Converts this
TimestampData object to a LocalDateTime . |
String |
toString() |
Timestamp |
toTimestamp()
Converts this
TimestampData object to a Timestamp . |
public long getMillisecond()
1970-01-01 00:00:00
.public int getNanoOfMillisecond()
The value range is from 0 to 999,999.
public Timestamp toTimestamp()
TimestampData
object to a Timestamp
.public java.time.LocalDateTime toLocalDateTime()
TimestampData
object to a LocalDateTime
.public java.time.Instant toInstant()
TimestampData
object to a Instant
.public int compareTo(TimestampData that)
compareTo
in interface Comparable<TimestampData>
public static TimestampData fromEpochMillis(long milliseconds)
TimestampData
from milliseconds.
The nanos-of-millisecond field will be set to zero.
milliseconds
- the number of milliseconds since 1970-01-01 00:00:00
; a negative
number is the number of milliseconds before 1970-01-01 00:00:00
public static TimestampData fromEpochMillis(long milliseconds, int nanosOfMillisecond)
TimestampData
from milliseconds and a nanos-of-millisecond.milliseconds
- the number of milliseconds since 1970-01-01 00:00:00
; a negative
number is the number of milliseconds before 1970-01-01 00:00:00
nanosOfMillisecond
- the nanoseconds within the millisecond, from 0 to 999,999public static TimestampData fromLocalDateTime(java.time.LocalDateTime dateTime)
TimestampData
from an instance of LocalDateTime
.dateTime
- an instance of LocalDateTime
public static TimestampData fromTimestamp(Timestamp timestamp)
TimestampData
from an instance of Timestamp
.timestamp
- an instance of Timestamp
public static TimestampData fromInstant(java.time.Instant instant)
TimestampData
from an instance of Instant
.instant
- an instance of Instant
public static boolean isCompact(int precision)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.