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 ofTimestampTypeandLocalZonedTimestampType.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 intcompareTo(TimestampData that)booleanequals(Object obj)static 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.longgetMillisecond()Returns the number of milliseconds since1970-01-01 00:00:00.intgetNanoOfMillisecond()Returns 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.InstanttoInstant()Converts thisTimestampDataobject to aInstant.LocalDateTimetoLocalDateTime()Converts thisTimestampDataobject to aLocalDateTime.StringtoString()TimestamptoTimestamp()Converts thisTimestampDataobject 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 thisTimestampDataobject to aTimestamp.
-
toLocalDateTime
public LocalDateTime toLocalDateTime()
Converts thisTimestampDataobject to aLocalDateTime.
-
toInstant
public Instant toInstant()
Converts thisTimestampDataobject to aInstant.
-
compareTo
public int compareTo(TimestampData that)
- Specified by:
compareToin interfaceComparable<TimestampData>
-
fromEpochMillis
public static TimestampData fromEpochMillis(long milliseconds)
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
public static TimestampData fromEpochMillis(long milliseconds, int nanosOfMillisecond)
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
public static TimestampData fromLocalDateTime(LocalDateTime dateTime)
Creates an instance ofTimestampDatafrom an instance ofLocalDateTime.- Parameters:
dateTime- an instance ofLocalDateTime
-
fromTimestamp
public static TimestampData fromTimestamp(Timestamp timestamp)
Creates an instance ofTimestampDatafrom an instance ofTimestamp.- Parameters:
timestamp- an instance ofTimestamp
-
fromInstant
public static TimestampData fromInstant(Instant instant)
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.
-
-