public final class Duration
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DAYS_PER_WEEK |
static int |
MONTHS_PER_YEAR |
static long |
NANOS_PER_HOUR |
static long |
NANOS_PER_MICRO |
static long |
NANOS_PER_MILLI |
static long |
NANOS_PER_MINUTE |
static long |
NANOS_PER_SECOND |
Modifier and Type | Method and Description |
---|---|
long |
addTo(long timeInMillis)
Adds this duration to the specified time in milliseconds.
|
boolean |
equals(java.lang.Object obj) |
static Duration |
from(java.lang.String input)
Converts a
String into a duration. |
int |
getDays() |
int |
getMonths() |
long |
getNanoseconds() |
boolean |
hasDayPrecision()
Checks if that duration has a day precision (nothing bellow the day level).
|
int |
hashCode() |
boolean |
hasMillisecondPrecision()
Checks if that duration has a millisecond precision (nothing bellow the millisecond level).
|
static Duration |
newInstance(int months,
int days,
long nanoseconds) |
long |
substractFrom(long timeInMillis)
Substracts this duration from the specified time in milliseconds.
|
java.lang.String |
toString() |
public static final long NANOS_PER_MICRO
public static final long NANOS_PER_MILLI
public static final long NANOS_PER_SECOND
public static final long NANOS_PER_MINUTE
public static final long NANOS_PER_HOUR
public static final int DAYS_PER_WEEK
public static final int MONTHS_PER_YEAR
public static Duration newInstance(int months, int days, long nanoseconds)
public static Duration from(java.lang.String input)
String
into a duration.
The accepted formats are:
y
: yearsm
: monthsw
: weeksd
: daysh
: hoursm
: minutess
: secondsms
: millisecondsus
or µs
: microsecondsns
: nanosecondsinput
- the String
to convertpublic int getMonths()
public int getDays()
public long getNanoseconds()
public long addTo(long timeInMillis)
timeInMillis
- the time to which the duration must be addedpublic long substractFrom(long timeInMillis)
timeInMillis
- the time from which the duration must be substractedpublic 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
public boolean hasDayPrecision()
true
if that duration has a day precision, false
otherwisepublic boolean hasMillisecondPrecision()
true
if that duration has a millisecond precision, false
otherwiseCopyright © 2009-2021 The Apache Software Foundation