Package org.apache.flink.table.data
Class TimestampData
- java.lang.Object
-
- org.apache.flink.table.data.TimestampData
-
- All Implemented Interfaces:
Comparable<TimestampData>
@PublicEvolving public final class TimestampData extends Object implements Comparable<TimestampData>
An internal data structure representing data ofTimestampType
andLocalZonedTimestampType
.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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(TimestampData that)
boolean
equals(Object obj)
static TimestampData
fromEpochMillis(long milliseconds)
Creates an instance ofTimestampData
from milliseconds.static TimestampData
fromEpochMillis(long milliseconds, int nanosOfMillisecond)
Creates an instance ofTimestampData
from milliseconds and a nanos-of-millisecond.static TimestampData
fromInstant(Instant instant)
Creates an instance ofTimestampData
from an instance ofInstant
.static TimestampData
fromLocalDateTime(LocalDateTime dateTime)
Creates an instance ofTimestampData
from an instance ofLocalDateTime
.static TimestampData
fromTimestamp(Timestamp timestamp)
Creates an instance ofTimestampData
from an instance ofTimestamp
.long
getMillisecond()
Returns the number of milliseconds since1970-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.Instant
toInstant()
Converts thisTimestampData
object to aInstant
.LocalDateTime
toLocalDateTime()
Converts thisTimestampData
object to aLocalDateTime
.String
toString()
Timestamp
toTimestamp()
Converts thisTimestampData
object to aTimestamp
.
-
-
-
Method Detail
-
getMillisecond
public long getMillisecond()
Returns the number of milliseconds since1970-01-01 00:00:00
.
-
getNanoOfMillisecond
public int getNanoOfMillisecond()
Returns the number of nanoseconds (the nanoseconds within the milliseconds).The value range is from 0 to 999,999.
-
toTimestamp
public Timestamp toTimestamp()
Converts thisTimestampData
object to aTimestamp
.
-
toLocalDateTime
public LocalDateTime toLocalDateTime()
Converts thisTimestampData
object to aLocalDateTime
.
-
toInstant
public Instant toInstant()
Converts thisTimestampData
object to aInstant
.
-
compareTo
public int compareTo(TimestampData that)
- Specified by:
compareTo
in interfaceComparable<TimestampData>
-
fromEpochMillis
public static TimestampData fromEpochMillis(long milliseconds)
Creates an instance ofTimestampData
from milliseconds.The nanos-of-millisecond field will be set to zero.
- Parameters:
milliseconds
- the number of milliseconds since1970-01-01 00:00:00
; a negative number is the number of milliseconds before1970-01-01 00:00:00
-
fromEpochMillis
public static TimestampData fromEpochMillis(long milliseconds, int nanosOfMillisecond)
Creates an instance ofTimestampData
from milliseconds and a nanos-of-millisecond.- Parameters:
milliseconds
- the number of milliseconds since1970-01-01 00:00:00
; a negative number is the number of milliseconds before1970-01-01 00:00:00
nanosOfMillisecond
- the nanoseconds within the millisecond, from 0 to 999,999
-
fromLocalDateTime
public static TimestampData fromLocalDateTime(LocalDateTime dateTime)
Creates an instance ofTimestampData
from an instance ofLocalDateTime
.- Parameters:
dateTime
- an instance ofLocalDateTime
-
fromTimestamp
public static TimestampData fromTimestamp(Timestamp timestamp)
Creates an instance ofTimestampData
from an instance ofTimestamp
.- Parameters:
timestamp
- an instance ofTimestamp
-
fromInstant
public static TimestampData fromInstant(Instant instant)
Creates an instance ofTimestampData
from an instance ofInstant
.- Parameters:
instant
- an instance ofInstant
-
isCompact
public static boolean isCompact(int precision)
Returns whether the timestamp data is small enough to be stored in a long of milliseconds.
-
-