Adds this duration to the specified temporal object.
Adds this duration to the specified temporal object.
This returns a temporal object of the same observable type as the input with this duration added.
In most cases, it is clearer to reverse the calling pattern by using
Temporal#plus(TemporalAmount)
.
// these two lines are equivalent, but the second approach is recommended dateTime = thisDuration.addTo(dateTime); dateTime = dateTime.plus(thisDuration);
The calculation will add the seconds, then nanos. Only non-zero amounts will be added.
This instance is immutable and unaffected by this method call.
the temporal object to adjust, not null
an object of the same type with the adjustment made, not null
ArithmeticException
if numeric overflow occurs
DateTimeException
if unable to add
Gets the value of the requested unit.
Gets the value of the requested unit.
This returns a value for each of the two supported units,
SECONDS
and NANOS
.
All other units throw an exception.
the { @code TemporalUnit} for which to return the value
the long value of the unit
DateTimeException
if the unit is not supported
UnsupportedTemporalTypeException
if the unit is not supported
Gets the set of units supported by this duration.
Gets the set of units supported by this duration.
The supported units are SECONDS
,
and NANOS
.
They are returned in the order seconds, nanos.
This set can be used in conjunction with #get(TemporalUnit)
to access the entire state of the duration.
a list containing the seconds and nanos units, not null
Is this seconds instance greater than the specified number of seconds.
Is this seconds instance greater than the specified number of seconds.
the other period, null means zero
true if this seconds instance is greater than the specified one
Is this seconds instance less than the specified number of seconds.
Is this seconds instance less than the specified number of seconds.
the other period, null means zero
true if this seconds instance is less than the specified one
Returns a new instance with the specified number of seconds taken away.
Returns a new instance with the specified number of seconds taken away.
This instance is immutable and unaffected by this method call.
the amount of seconds to take away, may be negative, null means zero
the new period minus the specified number of seconds
ArithmeticException
if the result overflows an int
Returns a new instance with the specified number of seconds added.
Returns a new instance with the specified number of seconds added.
This instance is immutable and unaffected by this method call.
the amount of seconds to add, may be negative, null means zero
the new period plus the specified number of seconds
ArithmeticException
if the result overflows an int
Gets the number of seconds that this period represents.
Gets the number of seconds that this period represents.
the number of seconds in the period
Subtracts this duration from the specified temporal object.
Subtracts this duration from the specified temporal object.
This returns a temporal object of the same observable type as the input with this duration subtracted.
In most cases, it is clearer to reverse the calling pattern by using
Temporal#minus(TemporalAmount)
.
// these two lines are equivalent, but the second approach is recommended dateTime = thisDuration.subtractFrom(dateTime); dateTime = dateTime.minus(thisDuration);
The calculation will subtract the seconds, then nanos. Only non-zero amounts will be added.
This instance is immutable and unaffected by this method call.
the temporal object to adjust, not null
an object of the same type with the adjustment made, not null
ArithmeticException
if numeric overflow occurs
DateTimeException
if unable to subtract
Gets this instance as a String in the ISO8601 duration format.
Gets this instance as a String in the ISO8601 duration format.
For example, "PT4S" represents 4 seconds.
the value as an ISO8601 string
An immutable time period representing a number of seconds.