public final class Duration
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
static Duration |
from(java.lang.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 Duration |
newInstance(int months,
int days,
long nanoseconds)
Creates a duration with the given number of months, days and nanoseconds.
|
java.lang.String |
toString() |
public static Duration 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 nanosecondsjava.lang.IllegalArgumentException
- if the values are not all negative or all positivepublic static Duration from(java.lang.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 convertDuration
public int getMonths()
public int getDays()
public long getNanoseconds()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2009-2022 The Apache Software Foundation