The number of nanoseconds in the duration, expressed as a fraction of the number of seconds. This is always positive, and never exceeds 999,999,999.
The number of seconds in the duration.
Returns a copy of this duration with a positive length.
This method returns a positive duration by effectively removing the sign from any negative total length.
For example, PT-1.3S
will be returned as PT1.3S
.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with an absolute length
ArithmeticException
if numeric overflow occurs
Compares this duration to the specified Duration.
The comparison is based on the total length of the durations.
It is "consistent with equals", as defined by Comparable
.
the comparator value, negative if less, positive if greater
the other duration to compare to
Returns a copy of this duration divided by the specified value.
This instance is immutable and unaffected by this method call.
a Duration based on this duration divided by the specified divisor
ArithmeticException
if the divisor is zero or if numeric overflow occurs
the value to divide the duration by, positive or negative, not zero
Returns number of whole times a specified Duration occurs within this Duration.
This instance is immutable and unaffected by this method call.
number of whole times, rounded toward zero, a specified Duration occurs within this Duration, may be negative
ArithmeticException
if the divisor is zero, or if numeric overflow occurs
the value to divide the duration by, positive or negative
Checks if this duration is negative, excluding zero.
A Duration represents a directed distance between two points on the time-line and can therefore be positive, zero or negative. This method checks whether the length is less than zero.
true if this duration has a total length less than zero
Checks if this duration is zero length.
A Duration represents a directed distance between two points on the time-line and can therefore be positive, zero or negative. This method checks whether the length is zero.
true if this duration has a total length equal to zero
Returns a copy of this duration with the specified duration subtracted.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified duration subtracted
ArithmeticException
if numeric overflow occurs
the duration to subtract, positive or negative
Returns a copy of this duration with the specified duration in standard 24 hour days subtracted.
The number of days is multiplied by 86400 to obtain the number of seconds to subtract. This is based on the standard definition of a day as 24 hours.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified days subtracted
ArithmeticException
if numeric overflow occurs
the days to subtract, positive or negative
Returns a copy of this duration with the specified duration in hours subtracted.
The number of hours is multiplied by 3600 to obtain the number of seconds to subtract.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified hours subtracted
ArithmeticException
if numeric overflow occurs
the hours to subtract, positive or negative
Returns a copy of this duration with the specified duration in milliseconds subtracted.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified milliseconds subtracted
ArithmeticException
if numeric overflow occurs
the milliseconds to subtract, positive or negative
Returns a copy of this duration with the specified duration in minutes subtracted.
The number of hours is multiplied by 60 to obtain the number of seconds to subtract.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified minutes subtracted
ArithmeticException
if numeric overflow occurs
the minutes to subtract, positive or negative
Returns a copy of this duration with the specified duration in nanoseconds subtracted.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified nanoseconds subtracted
ArithmeticException
if numeric overflow occurs
the nanoseconds to subtract, positive or negative
Returns a copy of this duration with the specified duration in seconds subtracted.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified seconds subtracted
ArithmeticException
if numeric overflow occurs
the seconds to subtract, positive or negative
Returns a copy of this duration multiplied by the scalar.
This instance is immutable and unaffected by this method call.
a Duration based on this duration multiplied by the specified scalar
ArithmeticException
if numeric overflow occurs
the value to multiply the duration by, positive or negative
Returns a copy of this duration with the length negated.
This method swaps the sign of the total length of this duration.
For example, PT1.3S
will be returned as PT-1.3S
.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the amount negated
ArithmeticException
if numeric overflow occurs
Returns a copy of this duration with the specified duration added.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified duration added
ArithmeticException if numeric overflow occurs
the duration to add, positive or negative
Returns a copy of this duration with the specified duration in standard 24 hour days added.
The number of days is multiplied by 86400 to obtain the number of seconds to add. This is based on the standard definition of a day as 24 hours.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified days added.
ArithmeticException
if numeric overflow occurs
the days to add, positive or negative
Returns a copy of this duration with the specified duration in hours added.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified hours added
ArithmeticException
if numeric overflow occurs
the hours to add, positive or negative
Returns a copy of this duration with the specified duration in milliseconds added.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified milliseconds added
ArithmeticException
if numeric overflow occurs
the milliseconds to add, positive or negative
Returns a copy of this duration with the specified duration in minutes added.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified minutes added
ArithmeticException if numeric overflow occurs
the minutes to add, positive or negative
Returns a copy of this duration with the specified duration in nanoseconds added.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified nanoseconds added
ArithmeticException
if numeric overflow occurs
the nanoseconds to add, positive or negative
Returns a copy of this duration with the specified duration in seconds added.
This instance is immutable and unaffected by this method call.
a Duration based on this duration with the specified seconds added
ArithmeticException
if numeric overflow occurs
the seconds to add, positive or negative
Gets the number of days in this duration.
This returns the total number of days in the duration by dividing the number of seconds by 86400. This is based on the standard definition of a day as 24 hours.
This instance is immutable and unaffected by this method call.
the number of days in the duration, may be negative
Extracts the number of days in the duration.
This returns the total number of days in the duration by dividing the number of seconds by 86400. This is based on the standard definition of a day as 24 hours.
This instance is immutable and unaffected by this method call.
the number of days in the duration, may be negative
Extracts the number of hours part in the duration.
This returns the number of remaining hours when dividing [toHours] by hours in a day. This is based on the standard definition of a day as 24 hours.
This instance is immutable and unaffected by this method call.
the number of hours part in the duration, may be negative
Converts this duration to the total length in milliseconds.
If this duration is too large to fit in a long
milliseconds, then an
exception is thrown.
If this duration has greater than millisecond precision, then the conversion will drop any excess precision information as though the amount in nanoseconds was subject to integer division by one million.
the total length of the duration in milliseconds
ArithmeticException
if numeric overflow occurs
Extracts the number of milliseconds part of the duration.
This returns the milliseconds part by dividing the number of nanoseconds by 1,000,000. The length of the duration is stored using two fields - seconds and nanoseconds. The nanoseconds part is a value from 0 to 999,999,999 that is an adjustment to the length in seconds. The total duration is defined by calling [nano] and [seconds].
This instance is immutable and unaffected by this method call.
the number of milliseconds part of the duration.
Gets the number of minutes in this duration.
This returns the total number of minutes in the duration by dividing the number of seconds by 60.
This instance is immutable and unaffected by this method call.
the number of minutes in the duration, may be negative
Extracts the number of minutes part in the duration.
This returns the number of remaining minutes when dividing [toMinutes] by minutes in an hour. This is based on the standard definition of an hour as 60 minutes.
This instance is immutable and unaffected by this method call.
the number of minutes parts in the duration, may be negative
Converts this duration to the total length in nanoseconds expressed as a long
.
If this duration is too large to fit in a long
nanoseconds, then an
exception is thrown.
the total length of the duration in nanoseconds
ArithmeticException
if numeric overflow occurs
Get the nanoseconds part within seconds of the duration.
The length of the duration is stored using two fields - seconds and nanoseconds. The nanoseconds part is a value from 0 to 999,999,999 that is an adjustment to the length in seconds. The total duration is defined by calling [nano] and [seconds].
This instance is immutable and unaffected by this method call.
the nanoseconds within the second part of the length of the duration, from 0 to 999,999,999
Extracts the number of seconds part in the duration.
This returns the remaining seconds when dividing [toSeconds] by seconds in a minute. This is based on the standard definition of a minute as 60 seconds.
This instance is immutable and unaffected by this method call.
the number of seconds parts in the duration, may be negative
Returns a copy of this duration with the specified nano-of-second.
This returns a duration with the specified nano-of-second, retaining the seconds part of this duration.
This instance is immutable and unaffected by this method call.
a Duration based on this period with the requested nano-of-second.
DateTimeException
if the nano-of-second is invalid
the nano-of-second to represent, from 0 to 999,999,999
Returns a copy of this duration with the specified amount of seconds.
This returns a duration with the specified seconds, retaining the nano-of-second part of this duration.
This instance is immutable and unaffected by this method call.
a Duration based on this period with the requested seconds
the seconds to represent, may be negative
Java Duration type.