What the Duration of negative Infinity mean?

Scott Palmer swpalmer at gmail.com
Thu Jan 31 18:07:49 PST 2013

On 2013-01-31, at 12:42 PM, Martin Sladecek <martin.sladecek at oracle.com> wrote:

> The other option is not to throw the exception and keep the Duration values above zero. If a > b, then b.subtract(a) will result in 0.

This may just be an intermediate value that is later added as in Richard's example.

But, I think this is over complicating things.  What exactly are we trying to accomplish?  A negative duration doesn't make sense as a *final value*, so in the context of setting the actual duration to use for an interval, I think it makes sense to disallow negative values, even though the Duration object is allowed to hold them.  It's no different than an API that takes integers where you must supply a positive value for the API to accept your input.

The SchedulerService can't use a negative duration unless you've incorporated time travel into it.  

For a general Duration, POSITIVE_INFINITY can map to isIndefinite, and NEGATIVE_INFINITY can be illegal or indefinite, either makes sense.


More information about the openjfx-dev mailing list