A related problem I recently met: there are objects with an expiration
attribute, but some of them are active forever. A special Instant
descendant class or constant value, similar to Double.POSITIVE_INFINITY,
would be more telling here then the other alternatives, e.g using null,
or an ad-hoc far-in-the-future date.
D.M. írta:
Has any thought been given to the implementation of unbounded
intervals? Right-unbounded intervals (extending into the future) are
often used as to represent an event that has begun, but has not yet
ended.
Whenever I need to permit an interval to be unbounded, I always use
two DateTimes instead, and allow one or both to have null values.
There are some disadvantages to this approach. One is that every
person who does this must write their own implementations of the
interval methods (contains, abuts, overlaps, etc.). Another
disadvantage is that the two DateTimes cannot be used as a key to a
map in the same way that an Interval can, unless they are wrapped in a
container class.
An alternative approach is to use Interval, with DateTime values
sufficiently far in the past/future representing infinity in either
direction. I don't like this approach because it feels imprecise, but
it is a quick and dirty way of getting Joda time to represent
unbounded intervals.
It would be nice if Joda had the ability to represent unbounded
intervals without such tricks. I'd be happy to help implement this
functionality if there is an interest. If there is an interest, how
might this be integrated? Add this functionality to the current
Interval implementation, or create a new type of interval capable of
representing unbounded intervals?
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest