Package org.apache.calcite.util
Class TimestampWithTimeZoneString
- java.lang.Object
-
- org.apache.calcite.util.TimestampWithTimeZoneString
-
- All Implemented Interfaces:
java.lang.Comparable<TimestampWithTimeZoneString>
public class TimestampWithTimeZoneString extends java.lang.Object implements java.lang.Comparable<TimestampWithTimeZoneString>
Timestamp with time-zone literal.Immutable, internally represented as a string (in ISO format), and can support unlimited precision (milliseconds, nanoseconds).
-
-
Field Summary
Fields Modifier and Type Field Description (package private) TimestampString
localDateTime
(package private) java.util.TimeZone
timeZone
(package private) java.lang.String
v
-
Constructor Summary
Constructors Constructor Description TimestampWithTimeZoneString(int year, int month, int day, int h, int m, int s, java.lang.String timeZone)
Creates a TimestampWithTimeZoneString for year, month, day, hour, minute, second, millisecond values in the given time-zone.TimestampWithTimeZoneString(java.lang.String v)
Creates a TimestampWithTimeZoneString.TimestampWithTimeZoneString(TimestampString localDateTime, java.util.TimeZone timeZone)
Creates a TimestampWithTimeZoneString.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(TimestampWithTimeZoneString o)
boolean
equals(java.lang.Object o)
static TimestampWithTimeZoneString
fromMillisSinceEpoch(long millis)
Creates a TimestampWithTimeZoneString that is a given number of milliseconds since the epoch UTC.DateString
getLocalDateString()
TimestampString
getLocalTimestampString()
TimeString
getLocalTimeString()
int
hashCode()
TimestampWithTimeZoneString
round(int precision)
java.lang.String
toString()
java.lang.String
toString(int precision)
Converts this TimestampWithTimeZoneString to a string, truncated or padded with zeroes to a given precision.TimestampWithTimeZoneString
withFraction(java.lang.String fraction)
Sets the fraction field of aTimestampString
.TimestampWithTimeZoneString
withMillis(int millis)
Sets the fraction field of aTimestampWithTimeZoneString
to a given number of milliseconds.TimestampWithTimeZoneString
withNanos(int nanos)
Sets the fraction field of aTimestampWithTimeZoneString
to a given number of nanoseconds.TimestampWithTimeZoneString
withTimeZone(java.util.TimeZone timeZone)
-
-
-
Field Detail
-
localDateTime
final TimestampString localDateTime
-
timeZone
final java.util.TimeZone timeZone
-
v
final java.lang.String v
-
-
Constructor Detail
-
TimestampWithTimeZoneString
public TimestampWithTimeZoneString(TimestampString localDateTime, java.util.TimeZone timeZone)
Creates a TimestampWithTimeZoneString.
-
TimestampWithTimeZoneString
public TimestampWithTimeZoneString(java.lang.String v)
Creates a TimestampWithTimeZoneString.
-
TimestampWithTimeZoneString
public TimestampWithTimeZoneString(int year, int month, int day, int h, int m, int s, java.lang.String timeZone)
Creates a TimestampWithTimeZoneString for year, month, day, hour, minute, second, millisecond values in the given time-zone.
-
-
Method Detail
-
withMillis
public TimestampWithTimeZoneString withMillis(int millis)
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
public TimestampWithTimeZoneString withNanos(int nanos)
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
public TimestampWithTimeZoneString withFraction(java.lang.String fraction)
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'
.
-
withTimeZone
public TimestampWithTimeZoneString withTimeZone(java.util.TimeZone timeZone)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(TimestampWithTimeZoneString o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<TimestampWithTimeZoneString>
-
round
public TimestampWithTimeZoneString round(int precision)
-
fromMillisSinceEpoch
public static TimestampWithTimeZoneString fromMillisSinceEpoch(long millis)
Creates a TimestampWithTimeZoneString that is a given number of milliseconds since the epoch UTC.
-
toString
public java.lang.String toString(int precision)
Converts this TimestampWithTimeZoneString to a string, truncated or padded with zeroes to a given precision.
-
getLocalDateString
public DateString getLocalDateString()
-
getLocalTimeString
public TimeString getLocalTimeString()
-
getLocalTimestampString
public TimestampString getLocalTimestampString()
-
-