Duration isPositive missing?

Roger Riggs Roger.Riggs at Oracle.com
Fri Dec 16 18:26:34 UTC 2016

Hi Steven,

Yes, it does seem like an oversight.  There are some other alternatives 
that might be considered.
     .toMillis() > 0    // Might throw an exception for very large or 
small durations.

I create an issue: 8171382 java.time.Duration missing isPositive method 

To look at it for the next release.


On 12/16/2016 12:54 PM, Steven Schlansker wrote:
> Hi core-libs-dev,
> My coworker and I were just puzzling over the seemingly trivially missing
> java.time.Duration#isPositive
> There are already "isNegative" and "isZero" -- but for isPositive the best
> we came up with were awful things like
> !isZero() && !isNegative()
> !.negate().isNegative()
> .compareTo(Duration.ZERO) > 0
> but all of these feel way worse than a simple isPositive method.
> Can you shed some light as to why this is missing?
> Thanks!
> Steven

More information about the core-libs-dev mailing list