RFR: 8171382: java.time.Duration missing isPositive method
Naoto Sato
naoto at openjdk.java.net
Fri Jul 23 20:03:06 UTC 2021
On Fri, 23 Jul 2021 19:37:44 GMT, Stephen Colebourne <scolebourne at openjdk.org> wrote:
>> Please review this PR to introduce `java.time.Duration.isPositive()` method. A CSR is also drafted.
>
> 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`.
Thanks, Stephen. Yes, `nanos` is even smaller, less than `1,000,000,000`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4892
More information about the core-libs-dev
mailing list