Class Interval (6.93.0)

public class Interval 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.

Inheritance

Object > Interval

Implements

Serializable

Static Methods

builder()

public static Interval.Builder builder()
Returns
Type Description
Interval.Builder

fromMonthsDaysNanos(int months, int days, BigInteger nanos)

public static Interval fromMonthsDaysNanos(int months, int days, BigInteger nanos)

Creates an interval with specified number of months, days and nanoseconds.

Parameters
Name Description
months int
days int
nanos BigInteger
Returns
Type Description
Interval

ofDays(int days)

public static Interval ofDays(int days)

Creates an interval with specified number of days.

Parameter
Name Description
days int
Returns
Type Description
Interval

ofMicros(long micros)

public static Interval ofMicros(long micros)

Creates an interval with specified number of microseconds.

Parameter
Name Description
micros long
Returns
Type Description
Interval

ofMillis(long millis)

public static Interval ofMillis(long millis)

Creates an interval with specified number of milliseconds.

Parameter
Name Description
millis long
Returns
Type Description
Interval

ofMonths(int months)

public static Interval ofMonths(int months)

Creates an interval with specified number of months.

Parameter
Name Description
months int
Returns
Type Description
Interval

ofNanos(BigInteger nanos)

public static Interval ofNanos(BigInteger nanos)

Creates an interval with specified number of nanoseconds.

Parameter
Name Description
nanos BigInteger
Returns
Type Description
Interval

ofSeconds(long seconds)

public static Interval ofSeconds(long seconds)

Creates an interval with specified number of seconds.

Parameter
Name Description
seconds long
Returns
Type Description
Interval

parseFromString(String interval)

public static Interval parseFromString(String interval)
Parameter
Name Description
interval String
Returns
Type Description
Interval

Methods

equals(Object rhs)

public boolean equals(Object rhs)
Parameter
Name Description
rhs Object
Returns
Type Description
boolean
Overrides

getDays()

public int getDays()

Returns the days component of the interval.

Returns
Type Description
int

getMonths()

public int getMonths()

Returns the months component of the interval.

Returns
Type Description
int

getNanos()

public BigInteger getNanos()

Returns the nanoseconds component of the interval.

Returns
Type Description
BigInteger

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

toISO8601()

public String toISO8601()

Converts Interval to ISO8601 duration format string.

Returns
Type Description
String

toString()

public String toString()
Returns
Type Description
String
Overrides