RFR: 8171382: java.time.Duration missing isPositive method

Stephen Colebourne scolebourne at openjdk.java.net
Fri Jul 23 19:41:02 UTC 2021


On Fri, 23 Jul 2021 17:27:27 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> Please review this PR to introduce `java.time.Duration.isPositive()` method. A CSR is also drafted.

Marked as reviewed by scolebourne (Author).

src/java.base/share/classes/java/time/Duration.java line 596:

> 594:      */
> 595:     public boolean isPositive() {
> 596:         return (seconds | nanos) > 0;

I had to think whether this logic is correct, but I believe it is because `nanos` is 32 bits and positive so won't impact the negative bit of `seconds`.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4892


More information about the core-libs-dev mailing list