public class SqlTimestamp extends Object implements Comparable<SqlTimestamp>
This class is composite of a millisecond and nanoOfMillisecond. The millisecond part holds the integral second and the milli-of-second. The nanoOfMillisecond holds the nano-of-millisecond, which should between 0 - 999_999.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(SqlTimestamp that) |
boolean |
equals(Object obj) |
static SqlTimestamp |
fromEpochMillis(long millisecond)
Obtains an instance of
SqlTimestamp from a millisecond. |
static SqlTimestamp |
fromEpochMillis(long millisecond,
int nanoOfMillisecond)
Obtains an instance of
SqlTimestamp from a millisecond and a nanoOfMillisecond. |
static SqlTimestamp |
fromInstant(java.time.Instant instant)
Obtains an instance of
SqlTimestamp from an instance of Instant . |
static SqlTimestamp |
fromLocalDateTime(java.time.LocalDateTime dateTime)
Obtains an instance of
SqlTimestamp from an instance of LocalDateTime . |
static SqlTimestamp |
fromTimestamp(Timestamp ts)
Obtains an instance of
SqlTimestamp from an instance of Timestamp . |
long |
getMillisecond() |
int |
getNanoOfMillisecond() |
int |
hashCode() |
static boolean |
isCompact(int precision)
Apache Calcite and Flink's planner use the number of milliseconds since epoch to represent a
Timestamp type compactly if the number of digits of fractional seconds is between 0 - 3.
|
static SqlTimestamp |
readTimestampFieldFromSegments(MemorySegment[] segments,
int baseOffset,
long offsetAndNanos)
Obtains an instance of
SqlTimestamp from underlying MemorySegment . |
java.time.Instant |
toInstant()
Convert this
SqlTimestamp object to a Instant . |
java.time.LocalDateTime |
toLocalDateTime()
Convert this
SqlTimestamp object to a LocalDateTime . |
String |
toString() |
Timestamp |
toTimestamp()
Convert this
SqlTimestmap object to a Timestamp . |
public int compareTo(SqlTimestamp that)
compareTo
in interface Comparable<SqlTimestamp>
public long getMillisecond()
public int getNanoOfMillisecond()
public static SqlTimestamp fromEpochMillis(long millisecond)
SqlTimestamp
from a millisecond.
This returns a SqlTimestamp
with the specified millisecond.
The nanoOfMillisecond field will be set to zero.
millisecond
- the number of milliseconds since January 1, 1970, 00:00:00 GMT
A negative number is the number of milliseconds before
January 1, 1970, 00:00:00 GMTSqlTimestamp
public static SqlTimestamp fromEpochMillis(long millisecond, int nanoOfMillisecond)
SqlTimestamp
from a millisecond and a nanoOfMillisecond.
This returns a SqlTimestamp
with the specified millisecond and nanoOfMillisecond.
millisecond
- the number of milliseconds since January 1, 1970, 00:00:00 GMT
A negative number is the number of milliseconds before
January 1, 1970, 00:00:00 GMTnanoOfMillisecond
- the nanosecond within the millisecond, from 0 to 999,999SqlTimestamp
public Timestamp toTimestamp()
SqlTimestmap
object to a Timestamp
.Timestamp
public static SqlTimestamp fromTimestamp(Timestamp ts)
SqlTimestamp
from an instance of Timestamp
.
This returns a SqlTimestamp
with the specified Timestamp
.
ts
- an instance of Timestamp
SqlTimestamp
public java.time.LocalDateTime toLocalDateTime()
SqlTimestamp
object to a LocalDateTime
.LocalDateTime
public static SqlTimestamp fromLocalDateTime(java.time.LocalDateTime dateTime)
SqlTimestamp
from an instance of LocalDateTime
.
This returns a SqlTimestamp
with the specified LocalDateTime
.
dateTime
- an instance of LocalDateTime
SqlTimestamp
public java.time.Instant toInstant()
SqlTimestamp
object to a Instant
.Instant
public static SqlTimestamp fromInstant(java.time.Instant instant)
SqlTimestamp
from an instance of Instant
.
This returns a SqlTimestmap
with the specified Instant
.
instant
- an instance of Instant
SqlTimestamp
public static boolean isCompact(int precision)
precision
- the number of digits of fractional secondspublic static SqlTimestamp readTimestampFieldFromSegments(MemorySegment[] segments, int baseOffset, long offsetAndNanos)
SqlTimestamp
from underlying MemorySegment
.segments
- the underlying MemorySegmentsbaseOffset
- the base offset of current instance of SqlTimestamp
offsetAndNanos
- the offset of millseconds part and nanosecondsSqlTimestamp
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.