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 Details

    • getMillisecond

      public long getMillisecond()
      Returns the number of milliseconds since 1970-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 this TimestampData object to a Timestamp.
    • toLocalDateTime

      public LocalDateTime toLocalDateTime()
      Converts this TimestampData object to a LocalDateTime.
    • toInstant

      public Instant toInstant()
      Converts this TimestampData object to a Instant.
    • compareTo

      public int compareTo(TimestampData that)
      Specified by:
      compareTo in interface Comparable<TimestampData>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fromEpochMillis

      public static TimestampData fromEpochMillis(long milliseconds)
      Creates an instance of TimestampData from milliseconds.

      The nanos-of-millisecond field will be set to zero.

      Parameters:
      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
    • fromEpochMillis

      public static TimestampData fromEpochMillis(long milliseconds, int nanosOfMillisecond)
      Creates an instance of TimestampData from milliseconds and a nanos-of-millisecond.
      Parameters:
      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,999
    • fromLocalDateTime

      public static TimestampData fromLocalDateTime(LocalDateTime dateTime)
      Creates an instance of TimestampData from an instance of LocalDateTime.
      Parameters:
      dateTime - an instance of LocalDateTime
    • fromTimestamp

      public static TimestampData fromTimestamp(Timestamp timestamp)
      Creates an instance of TimestampData from an instance of Timestamp.
      Parameters:
      timestamp - an instance of Timestamp
    • fromInstant

      public static TimestampData fromInstant(Instant instant)
      Creates an instance of TimestampData from an instance of Instant.
      Parameters:
      instant - an instance of Instant
    • isCompact

      public static boolean isCompact(int precision)
      Returns whether the timestamp data is small enough to be stored in a long of milliseconds.