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 Details

    • TimestampWithTimeZoneString

      public TimestampWithTimeZoneString(TimestampString localDateTime, TimeZone timeZone)
      Creates a TimestampWithTimeZoneString.
    • TimestampWithTimeZoneString

      public TimestampWithTimeZoneString(String v)
      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

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

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

    • withNanos

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

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

    • withFraction

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

    • fromCalendarFields

      public static TimestampWithTimeZoneString fromCalendarFields(Calendar calendar)
      Creates a TimestampWithTimeZoneString from a Calendar.
    • withTimeZone

      public TimestampWithTimeZoneString 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(TimestampWithTimeZoneString o)
      Specified by:
      compareTo in interface 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 String toString(int precision)
      Converts this TimestampWithTimeZoneString to a string, truncated or padded with zeros to a given precision.
    • getLocalDateString

      public DateString getLocalDateString()
    • getLocalTimeString

      public TimeString getLocalTimeString()
    • getLocalTimestampString

      public TimestampString getLocalTimestampString()
    • getTimeZone

      public TimeZone getTimeZone()