Class TimeWithTimeZoneString

java.lang.Object
org.apache.calcite.util.TimeWithTimeZoneString
All Implemented Interfaces:
Comparable<TimeWithTimeZoneString>

public class TimeWithTimeZoneString extends Object implements Comparable<TimeWithTimeZoneString>
Time with time-zone literal.

Immutable, internally represented as a string (in ISO format), and can support unlimited precision (milliseconds, nanoseconds).

  • Constructor Details

    • TimeWithTimeZoneString

      public TimeWithTimeZoneString(TimeString localTime, TimeZone timeZone)
      Creates a TimeWithTimeZoneString.
    • TimeWithTimeZoneString

      public TimeWithTimeZoneString(String v)
      Creates a TimeWithTimeZoneString.
    • TimeWithTimeZoneString

      public TimeWithTimeZoneString(int h, int m, int s, String timeZone)
      Creates a TimeWithTimeZoneString for hour, minute, second and millisecond values in the given time-zone.
  • Method Details

    • withMillis

      public TimeWithTimeZoneString withMillis(int millis)
      Sets the fraction field of a TimeWithTimeZoneString to a given number of milliseconds. Nukes the value set via withNanos(int).

      For example, new TimeWithTimeZoneString(1970, 1, 1, 2, 3, 4, "UTC").withMillis(56) yields TIME WITH LOCAL TIME ZONE '1970-01-01 02:03:04.056 UTC'.

    • withNanos

      public TimeWithTimeZoneString withNanos(int nanos)
      Sets the fraction field of a TimeString to a given number of nanoseconds. Nukes the value set via withMillis(int).

      For example, new TimeWithTimeZoneString(1970, 1, 1, 2, 3, 4, "UTC").withNanos(56789) yields TIME WITH LOCAL TIME ZONE '1970-01-01 02:03:04.000056789 UTC'.

    • withFraction

      public TimeWithTimeZoneString withFraction(String fraction)
      Sets the fraction field of a TimeWithTimeZoneString. 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") yields TIME WITH LOCAL TIME ZONE '1970-01-01 02:03:04.00506 UTC'.

    • withTimeZone

      public TimeWithTimeZoneString withTimeZone(TimeZone timeZone)
    • toString

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

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public int compareTo(TimeWithTimeZoneString o)
      Specified by:
      compareTo in interface Comparable<TimeWithTimeZoneString>
    • round

      public TimeWithTimeZoneString round(int precision)
    • fromMillisOfDay

      public static TimeWithTimeZoneString fromMillisOfDay(int i)
    • toString

      public String toString(int precision)
      Converts this TimeWithTimeZoneString to a string, truncated or padded with zeros to a given precision.
    • getLocalTimeString

      public TimeString getLocalTimeString()