mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8171382: java.time.Duration missing isPositive method
Reviewed-by: rriggs, joehw, iris, bpb, scolebourne
This commit is contained in:
parent
ee5536183a
commit
efa63dc1c6
2 changed files with 31 additions and 1 deletions
|
@ -582,6 +582,20 @@ public final class Duration
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Checks if this duration is positive, excluding zero.
|
||||
* <p>
|
||||
* A {@code 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 greater than zero.
|
||||
*
|
||||
* @return true if this duration has a total length greater than zero
|
||||
* @since 18
|
||||
*/
|
||||
public boolean isPositive() {
|
||||
return (seconds | nanos) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this duration is zero length.
|
||||
* <p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue