Duration.MAX_VALUE

Stephen Colebourne scolebourne at joda.org
Fri Sep 26 07:02:46 UTC 2025


On Tue, 23 Sept 2025 at 20:44, Pavel Rappo <pavel.rappo at gmail.com> wrote:
> If the timeout is a big (but not necessarily maximum) Duration, every
> option above has hazards.

*Any* method that receives a Duration has hazards around the size of
the duration, and as such should validate the input.

Again, this is no different to a method that accepts `long duration`,
which can also break semantics if the method does not correctly
validate the input.

Duration.MAX and MIN should be added.
1) they are hard to create manually with knowledge applications should not have
2) useful in a variety of scenarios
3) no different to Instant.MAX/MIN which can also be misused
4) needed for consistency with all other java.time.* classes

BTW, I don't have a philosophical objection to saturated maths
methods, but whether they exist of not is not really relevant here, as
the concerns those methods would be targetted at already exist today.

Stephen


More information about the core-libs-dev mailing list