Class Duration
java.lang.Object
org.apache.cassandra.cql3.functions.types.Duration
Represents a duration. A duration stores separately months, days, and seconds 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.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic DurationConverts aStringinto a duration.intgetDays()Returns the number of days in this duration.intReturns the number of months in this duration.longReturns the number of nanoseconds in this duration.inthashCode()static DurationnewInstance(int months, int days, long nanoseconds) Creates a duration with the given number of months, days and nanoseconds.toString()
-
Method Details
-
newInstance
Creates a duration with the given number of months, days and nanoseconds.A duration can be negative. In this case, all the non zero values must be negative.
- Parameters:
months- the number of monthsdays- the number of daysnanoseconds- the number of nanoseconds- Throws:
IllegalArgumentException- if the values are not all negative or all positive
-
from
Converts aStringinto a duration.The accepted formats are:
- multiple digits followed by a time unit like: 12h30m where the time unit can be:
y: yearsm: monthsw: weeksd: daysh: hoursm: minutess: secondsms: millisecondsusorµs: microsecondsns: nanoseconds
- ISO 8601 format: P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W
- ISO 8601 alternative format: P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]
- Parameters:
input- theStringto convert- Returns:
- a
Duration
- multiple digits followed by a time unit like: 12h30m where the time unit can be:
-
getMonths
public int getMonths()Returns the number of months in this duration.- Returns:
- the number of months in this duration.
-
getDays
public int getDays()Returns the number of days in this duration.- Returns:
- the number of days in this duration.
-
getNanoseconds
public long getNanoseconds()Returns the number of nanoseconds in this duration.- Returns:
- the number of months in this duration.
-
hashCode
public int hashCode() -
equals
-
toString
-