Duration (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Serializable, Comparable<Duration>, TemporalAmount
-
Field Summary
Fields
The maximum supported
Duration, which isLong.MAX_VALUEseconds and999,999,999nanoseconds.Constant for a duration of zero.
-
Method Summary
abs()Returns a copy of this duration with a positive length.
Adds this duration to the specified temporal object.
Obtains a
Durationrepresenting the duration between two temporal objects.intCompares this duration to the specified
Duration.dividedBy(long divisor) Returns a copy of this duration divided by the specified value.
longReturns number of whole times a specified Duration occurs within this Duration.
booleanChecks if this duration is equal to the specified
Duration.Obtains an instance of
Durationfrom a temporal amount.longGets the value of the requested unit.
intgetNano()Gets the number of nanoseconds within the second in this duration.
longGets the number of seconds in this duration.
getUnits()Gets the set of units supported by this duration.
inthashCode()A hash code for this duration.
booleanChecks if this duration is negative, excluding zero.
booleanChecks if this duration is positive, excluding zero.
booleanisZero()Checks if this duration is zero length.
Returns a copy of this duration with the specified duration subtracted.
Returns a copy of this duration with the specified duration subtracted.
minusDays(long daysToSubtract) Returns a copy of this duration with the specified duration in standard 24 hour days subtracted.
minusHours(long hoursToSubtract) Returns a copy of this duration with the specified duration in hours subtracted.
minusMillis(long millisToSubtract) Returns a copy of this duration with the specified duration in milliseconds subtracted.
minusMinutes(long minutesToSubtract) Returns a copy of this duration with the specified duration in minutes subtracted.
minusNanos(long nanosToSubtract) Returns a copy of this duration with the specified duration in nanoseconds subtracted.
minusSeconds(long secondsToSubtract) Returns a copy of this duration with the specified duration in seconds subtracted.
multipliedBy(long multiplicand) Returns a copy of this duration multiplied by the scalar.
negated()Returns a copy of this duration with the length negated.
Obtains a
Durationrepresenting an amount in the specified unit.ofDays(long days) Obtains a
Durationrepresenting a number of standard 24 hour days.ofHours(long hours) Obtains a
Durationrepresenting a number of standard hours.ofMillis(long millis) Obtains a
Durationrepresenting a number of milliseconds.ofMinutes(long minutes) Obtains a
Durationrepresenting a number of standard minutes.ofNanos(long nanos) Obtains a
Durationrepresenting a number of nanoseconds.ofSeconds(long seconds) Obtains a
Durationrepresenting a number of seconds.ofSeconds(long seconds, long nanoAdjustment) Obtains a
Durationrepresenting a number of seconds and an adjustment in nanoseconds.Obtains a
Durationfrom a text string such asPnDTnHnMn.nS.Returns a copy of this duration with the specified duration added.
Returns a copy of this duration with the specified duration added.
plusDays(long daysToAdd) Returns a copy of this duration with the specified duration in standard 24 hour days added.
plusHours(long hoursToAdd) Returns a copy of this duration with the specified duration in hours added.
plusMillis(long millisToAdd) Returns a copy of this duration with the specified duration in milliseconds added.
plusMinutes(long minutesToAdd) Returns a copy of this duration with the specified duration in minutes added.
plusNanos(long nanosToAdd) Returns a copy of this duration with the specified duration in nanoseconds added.
plusSeconds(long secondsToAdd) Returns a copy of this duration with the specified duration in seconds added.
Subtracts this duration from the specified temporal object.
longtoDays()Gets the number of days in this duration.
longExtracts the number of days in the duration.
longtoHours()Gets the number of hours in this duration.
intExtracts the number of hours part in the duration.
longtoMillis()Converts this duration to the total length in milliseconds.
intExtracts the number of milliseconds part of the duration.
longGets the number of minutes in this duration.
intExtracts the number of minutes part in the duration.
longtoNanos()Converts this duration to the total length in nanoseconds expressed as a
long.intGet the nanoseconds part within seconds of the duration.
longGets the number of seconds in this duration.
intExtracts the number of seconds part in the duration.
toString()A string representation of this duration using ISO-8601 seconds based representation, such as
PT8H6M12.345S.Returns a copy of this
Durationtruncated to the specified unit.withNanos(int nanoOfSecond) Returns a copy of this duration with the specified nano-of-second.
withSeconds(long seconds) Returns a copy of this duration with the specified amount of seconds.
Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
ZERO
-
MIN
-
MAX
-
-
Method Details
-
ofDays
-
ofHours
-
ofMinutes
-
ofSeconds
-
ofSeconds
-
ofMillis
-
ofNanos
-
of
-
from
-
parse
-
between
-
get
-
getUnits
-
isPositive
-
isZero
-
isNegative
-
getSeconds
-
getNano
-
withSeconds
-
withNanos
-
plus
-
plus
-
plusDays
-
plusHours
-
plusMinutes
-
plusSeconds
-
plusMillis
-
plusNanos
-
minus
-
minus
-
minusDays
-
minusHours
-
minusMinutes
-
minusSeconds
-
minusMillis
-
minusNanos
-
multipliedBy
-
dividedBy
-
dividedBy
-
negated
-
abs
-
addTo
-
subtractFrom
-
toDays
-
toHours
-
toMinutes
-
toSeconds
-
toMillis
-
toNanos
-
toDaysPart
-
toHoursPart
-
toMinutesPart
-
toSecondsPart
-
toMillisPart
-
toNanosPart
-
truncatedTo
-
compareTo
-
equals
-
hashCode
-
toString
-