Quantcast

unbounded intervals?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

unbounded intervals?

D.M.-2
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unbounded intervals?

Hontvári József
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. <script language="JScript" src="/j2se6/H2HHinclude.js"></script>

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&#174; 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest

  


------------------------------------------------------------------------------
Download Intel&#174; 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unbounded intervals?

jodastephen
In reply to this post by D.M.-2
(Currently on holiday)

Unbounded intervals have always been out of scope for Joda-Time,
partly because they mess with your expectations when using the API
(everybody typically needs to constantly check for the edge cases).

I wouldn´t plan on adding them or accepting patches. I´d recommend
your own domain objects to handle these cases. Or if you want to open
source, set up your own project and I´ll link to it from Joda-Time.

Stephen


On 1 April 2010 19:21, D.M. <[hidden email]> wrote:

> 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&#174; 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Download Intel&#174; 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...