8171382: java.time.Duration missing isPositive method

Reviewed-by: rriggs, joehw, iris, bpb, scolebourne
This commit is contained in:
Naoto Sato 2021-07-26 16:33:16 +00:00
parent ee5536183a
commit efa63dc1c6
2 changed files with 31 additions and 1 deletions

View file

@ -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>