@Immutable public final class CqlDuration extends Object
It stores months, days, and seconds separately due to the fact that the number of days in a
month varies, and a day can have 23 or 25 hours if a daylight saving is involved. As such, this
type differs from Duration
(which only represents an amount between two points
in time, regardless of the calendar).
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
static CqlDuration |
from(String input)
Converts a
String into a duration. |
int |
getDays()
Returns the number of days in this duration.
|
int |
getMonths()
Returns the number of months in this duration.
|
long |
getNanoseconds()
Returns the number of nanoseconds in this duration.
|
int |
hashCode() |
static CqlDuration |
newInstance(int months,
int days,
long nanoseconds)
Creates a duration with the given number of months, days and nanoseconds.
|
String |
toString() |
public static CqlDuration newInstance(int months, int days, long nanoseconds)
A duration can be negative. In this case, all the non zero values must be negative.
months
- the number of monthsdays
- the number of daysnanoseconds
- the number of nanosecondsIllegalArgumentException
- if the values are not all negative or all positivepublic static CqlDuration from(@NonNull String input)
String
into a duration.
The accepted formats are:
y
: years
m
: months
w
: weeks
d
: days
h
: hours
m
: minutes
s
: seconds
ms
: milliseconds
us
or µs
: microseconds
ns
: nanoseconds
input
- the String
to convertpublic int getMonths()
public int getDays()
public long getNanoseconds()
Copyright © 2017–2018. All rights reserved.