Package org.apache.calcite.util
Class TimeWithTimeZoneString
- java.lang.Object
-
- org.apache.calcite.util.TimeWithTimeZoneString
-
- All Implemented Interfaces:
java.lang.Comparable<TimeWithTimeZoneString>
public class TimeWithTimeZoneString extends java.lang.Object implements java.lang.Comparable<TimeWithTimeZoneString>
Time 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) TimeString
localTime
(package private) java.util.TimeZone
timeZone
(package private) java.lang.String
v
-
Constructor Summary
Constructors Constructor Description TimeWithTimeZoneString(int h, int m, int s, java.lang.String timeZone)
Creates a TimeWithTimeZoneString for hour, minute, second and millisecond values in the given time-zone.TimeWithTimeZoneString(java.lang.String v)
Creates a TimeWithTimeZoneString.TimeWithTimeZoneString(TimeString localTime, java.util.TimeZone timeZone)
Creates a TimeWithTimeZoneString.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(TimeWithTimeZoneString o)
boolean
equals(java.lang.Object o)
static TimeWithTimeZoneString
fromMillisOfDay(int i)
TimeString
getLocalTimeString()
int
hashCode()
TimeWithTimeZoneString
round(int precision)
java.lang.String
toString()
java.lang.String
toString(int precision)
Converts this TimeWithTimeZoneString to a string, truncated or padded with zeroes to a given precision.TimeWithTimeZoneString
withFraction(java.lang.String fraction)
Sets the fraction field of aTimeWithTimeZoneString
.TimeWithTimeZoneString
withMillis(int millis)
Sets the fraction field of aTimeWithTimeZoneString
to a given number of milliseconds.TimeWithTimeZoneString
withNanos(int nanos)
Sets the fraction field of aTimeString
to a given number of nanoseconds.TimeWithTimeZoneString
withTimeZone(java.util.TimeZone timeZone)
-
-
-
Field Detail
-
localTime
final TimeString localTime
-
timeZone
final java.util.TimeZone timeZone
-
v
final java.lang.String v
-
-
Constructor Detail
-
TimeWithTimeZoneString
public TimeWithTimeZoneString(TimeString localTime, java.util.TimeZone timeZone)
Creates a TimeWithTimeZoneString.
-
TimeWithTimeZoneString
public TimeWithTimeZoneString(java.lang.String v)
Creates a TimeWithTimeZoneString.
-
TimeWithTimeZoneString
public TimeWithTimeZoneString(int h, int m, int s, java.lang.String timeZone)
Creates a TimeWithTimeZoneString for hour, minute, second and millisecond values in the given time-zone.
-
-
Method Detail
-
withMillis
public TimeWithTimeZoneString withMillis(int millis)
Sets the fraction field of aTimeWithTimeZoneString
to a given number of milliseconds. Nukes the value set viawithNanos(int)
.For example,
new TimeWithTimeZoneString(1970, 1, 1, 2, 3, 4, "UTC").withMillis(56)
yieldsTIME WITH LOCAL TIME ZONE '1970-01-01 02:03:04.056 UTC'
.
-
withNanos
public TimeWithTimeZoneString withNanos(int nanos)
Sets the fraction field of aTimeString
to a given number of nanoseconds. Nukes the value set viawithMillis(int)
.For example,
new TimeWithTimeZoneString(1970, 1, 1, 2, 3, 4, "UTC").withNanos(56789)
yieldsTIME WITH LOCAL TIME ZONE '1970-01-01 02:03:04.000056789 UTC'
.
-
withFraction
public TimeWithTimeZoneString withFraction(java.lang.String fraction)
Sets the fraction field of aTimeWithTimeZoneString
. The precision is determined by the number of leading zeros. Trailing zeros are stripped.For example,
new TimeWithTimeZoneString(1970, 1, 1, 2, 3, 4, "UTC").withFraction("00506000")
yieldsTIME WITH LOCAL TIME ZONE '1970-01-01 02:03:04.00506 UTC'
.
-
withTimeZone
public TimeWithTimeZoneString 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(TimeWithTimeZoneString o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<TimeWithTimeZoneString>
-
round
public TimeWithTimeZoneString round(int precision)
-
fromMillisOfDay
public static TimeWithTimeZoneString fromMillisOfDay(int i)
-
toString
public java.lang.String toString(int precision)
Converts this TimeWithTimeZoneString to a string, truncated or padded with zeroes to a given precision.
-
getLocalTimeString
public TimeString getLocalTimeString()
-
-