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 of
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.
-
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(TimestampData that) booleanstatic TimestampDatafromEpochMillis(long milliseconds) Creates an instance ofTimestampDatafrom milliseconds.static TimestampDatafromEpochMillis(long milliseconds, int nanosOfMillisecond) Creates an instance ofTimestampDatafrom milliseconds and a nanos-of-millisecond.static TimestampDatafromInstant(Instant instant) Creates an instance ofTimestampDatafrom an instance ofInstant.static TimestampDatafromLocalDateTime(LocalDateTime dateTime) Creates an instance ofTimestampDatafrom an instance ofLocalDateTime.static TimestampDatafromTimestamp(Timestamp timestamp) Creates an instance ofTimestampDatafrom an instance ofTimestamp.longReturns the number of milliseconds since1970-01-01 00:00:00.intReturns the number of nanoseconds (the nanoseconds within the milliseconds).inthashCode()static booleanisCompact(int precision) Returns whether the timestamp data is small enough to be stored in a long of milliseconds.Converts thisTimestampDataobject to aInstant.Converts thisTimestampDataobject to aLocalDateTime.toString()Converts thisTimestampDataobject to aTimestamp.
-
Method Details
-
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
Converts thisTimestampDataobject to aTimestamp. -
toLocalDateTime
Converts thisTimestampDataobject to aLocalDateTime. -
toInstant
Converts thisTimestampDataobject to aInstant. -
compareTo
- Specified by:
compareToin interfaceComparable<TimestampData>
-
equals
-
toString
-
hashCode
public int hashCode() -
fromEpochMillis
Creates an instance ofTimestampDatafrom 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
Creates an instance ofTimestampDatafrom 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:00nanosOfMillisecond- the nanoseconds within the millisecond, from 0 to 999,999
-
fromLocalDateTime
Creates an instance ofTimestampDatafrom an instance ofLocalDateTime.- Parameters:
dateTime- an instance ofLocalDateTime
-
fromTimestamp
Creates an instance ofTimestampDatafrom an instance ofTimestamp.- Parameters:
timestamp- an instance ofTimestamp
-
fromInstant
Creates an instance ofTimestampDatafrom 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.
-