public final class Duration extends Object
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
static Duration |
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 Duration |
newInstance(int months,
int days,
long nanoseconds)
Creates a duration with the given number of months, days and nanoseconds.
|
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 nanosecondsIllegalArgumentException
- if the values are not all negative or all positivepublic static Duration from(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()
Copyright © 2012–2020. All rights reserved.