Package org.apache.calcite.util
Class TimestampWithTimeZoneString
java.lang.Object
org.apache.calcite.util.TimestampWithTimeZoneString
- All Implemented Interfaces:
Comparable<TimestampWithTimeZoneString>
public class TimestampWithTimeZoneString
extends Object
implements Comparable<TimestampWithTimeZoneString>
Timestamp with time-zone literal.
Immutable, internally represented as a string (in ISO format), and can support unlimited precision (milliseconds, nanoseconds).
-
Constructor Summary
ConstructorDescriptionTimestampWithTimeZoneString
(int year, int month, int day, int h, int m, int s, String timeZone) Creates a TimestampWithTimeZoneString for year, month, day, hour, minute, second, millisecond values in the given time-zone.Creates a TimestampWithTimeZoneString.TimestampWithTimeZoneString
(TimestampString localDateTime, TimeZone timeZone) Creates a TimestampWithTimeZoneString. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
static TimestampWithTimeZoneString
fromCalendarFields
(Calendar calendar) Creates a TimestampWithTimeZoneString from a Calendar.static TimestampWithTimeZoneString
fromMillisSinceEpoch
(long millis) Creates a TimestampWithTimeZoneString that is a given number of milliseconds since the epoch UTC.int
hashCode()
round
(int precision) toString()
toString
(int precision) Converts this TimestampWithTimeZoneString to a string, truncated or padded with zeros to a given precision.withFraction
(String fraction) Sets the fraction field of aTimestampString
.withMillis
(int millis) Sets the fraction field of aTimestampWithTimeZoneString
to a given number of milliseconds.withNanos
(int nanos) Sets the fraction field of aTimestampWithTimeZoneString
to a given number of nanoseconds.withTimeZone
(TimeZone timeZone)
-
Constructor Details
-
TimestampWithTimeZoneString
Creates a TimestampWithTimeZoneString. -
TimestampWithTimeZoneString
Creates a TimestampWithTimeZoneString. -
TimestampWithTimeZoneString
public TimestampWithTimeZoneString(int year, int month, int day, int h, int m, int s, String timeZone) Creates a TimestampWithTimeZoneString for year, month, day, hour, minute, second, millisecond values in the given time-zone.
-
-
Method Details
-
withMillis
Sets the fraction field of aTimestampWithTimeZoneString
to a given number of milliseconds. Nukes the value set viawithNanos(int)
.For example,
new TimestampWithTimeZoneString(1970, 1, 1, 2, 3, 4, "GMT").withMillis(56)
yieldsTIMESTAMP WITH LOCAL TIME ZONE '1970-01-01 02:03:04.056 GMT'
. -
withNanos
Sets the fraction field of aTimestampWithTimeZoneString
to a given number of nanoseconds. Nukes the value set viawithMillis(int)
.For example,
new TimestampWithTimeZoneString(1970, 1, 1, 2, 3, 4, "GMT").withNanos(56789)
yieldsTIMESTAMP WITH LOCAL TIME ZONE '1970-01-01 02:03:04.000056789 GMT'
. -
withFraction
Sets the fraction field of aTimestampString
. The precision is determined by the number of leading zeros. Trailing zeros are stripped.For example,
new TimestampWithTimeZoneString(1970, 1, 1, 2, 3, 4, "GMT").withFraction("00506000")
yieldsTIMESTAMP WITH LOCAL TIME ZONE '1970-01-01 02:03:04.00506 GMT'
. -
fromCalendarFields
Creates a TimestampWithTimeZoneString from a Calendar. -
withTimeZone
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<TimestampWithTimeZoneString>
-
round
-
fromMillisSinceEpoch
Creates a TimestampWithTimeZoneString that is a given number of milliseconds since the epoch UTC. -
toString
Converts this TimestampWithTimeZoneString to a string, truncated or padded with zeros to a given precision. -
getLocalDateString
-
getLocalTimeString
-
getLocalTimestampString
-
getTimeZone
-