Consider adding utilities related to java.time.Duration #1217
Closed
sleberknight
started this conversation in
Ideas
Replies: 2 comments
-
I just checked Apache Commons Lang and it contains a if (duration.isZero() || DurationUtils.isPositive(duration)) { ... } This code is also a bit annoying since one method is an instance method and the other is a static method, so it looks inconsistent. Nit picky? Sure. But I guess I'd rather just call one method in a consistent way. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing this as it will be fixed by #1221 in version 4.6.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've recently been annoyed that
java.time.Duration
containsisZero()
andisNegative()
methods but no other variants. My specific use case called for checking if aDuration
was zero or positive, which meant I had to use!duration.isNegative()
. It's obviously not a huge problem, but reading:is less clear and takes more time for a reader to parse than:
Especially since you might quickly read "not negative" as "positive" and not "zero or positive". (Or maybe that's just me).
Since I clearly can't add what I want to
java.time.Duration
(unless Java ever adds extension methods like in Kotlin and other languages), we could add some methods to aKiwiDurations
utility to cover the common cases of:Beta Was this translation helpful? Give feedback.
All reactions