Class Interval

java.lang.Object
com.google.cloud.spanner.Interval
All Implemented Interfaces:
Serializable

@Immutable public class Interval extends Object implements Serializable
Represents the time duration as a combination of months, days and nanoseconds. Nanoseconds are broken into two components microseconds and nanoFractions, where nanoFractions can range from [-999, 999]. Internally, Spanner supports Interval value with the following range of individual fields: months: [-120000, 120000] days: [-3660000, 3660000] nanoseconds: [-316224000000000000000, 316224000000000000000]. Interval value created outside the specified domain will return error when sent to Spanner backend.
See Also:
  • Method Details

    • getMonths

      public int getMonths()
      Returns the months component of the interval.
    • getDays

      public int getDays()
      Returns the days component of the interval.
    • getNanos

      public BigInteger getNanos()
      Returns the nanoseconds component of the interval.
    • builder

      public static Interval.Builder builder()
    • ofMonths

      public static Interval ofMonths(int months)
      Creates an interval with specified number of months.
    • ofDays

      public static Interval ofDays(int days)
      Creates an interval with specified number of days.
    • ofSeconds

      public static Interval ofSeconds(long seconds)
      Creates an interval with specified number of seconds.
    • ofMillis

      public static Interval ofMillis(long millis)
      Creates an interval with specified number of milliseconds.
    • ofMicros

      public static Interval ofMicros(long micros)
      Creates an interval with specified number of microseconds.
    • ofNanos

      public static Interval ofNanos(BigInteger nanos)
      Creates an interval with specified number of nanoseconds.
    • fromMonthsDaysNanos

      public static Interval fromMonthsDaysNanos(int months, int days, BigInteger nanos)
      Creates an interval with specified number of months, days and nanoseconds.
    • parseFromString

      public static Interval parseFromString(String interval)
    • toISO8601

      public String toISO8601()
      Converts Interval to ISO8601 duration format string.
    • toString

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

      public boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object