Thank-you for the pointer. I looked over the API for the JODA Interval class. When reading the docs, I somehow missed the methods that Interval inherits from *AbstractInterval *and *ReadableInterval*. Consequently, *Interval *didn't seem suitable because the concrete class *Interval *doesn't contain methods such as "*getStart*" and "*getEnd*". Obviously, once you include the methods that it inherits, it has everything that I am looking for except being /Comparable/. Mia Culpa!

I would disagree (mildly) with the assertion that there is not a suitable definition for *Interval *being /Comparable/. I believe that the problem is not that there isn't a suitable definition; rather the problem is that there are at least /four/ suitable definitions that come to mind; all of which are defensible, and different users would argue vehemently for their favorite choice: The four that come to mind are: StartDate, EndDate, millisecond length of interval, and a combination of the first two.

Example:

If ( getStart() != other.getStart() ) { // returns the difference of the 
starting date
    return( other.getStart().getMillis() - getStart().getMillis() );

} else { // returns zero[equal] if the end_dates and the start_dates are the 
same

    return( other.getEnd().getMillis() - getEnd().getMillis() );

}


On 11/3/2011 4:57 PM, Stephen Colebourne wrote:
Well Joda-Time Interval class stores two DateTime objects, so surely
basically fulfills your definition. It can't be comparable as there is
no suitable definition.

If Interval isn't suitable, then there isn't any other class available
in the library.

Stephen


On 3 November 2011 20:34, A. Rick Anderson<ar...@pobox.com>  wrote:
I am looking for a class that would seem to me to be a basic and
recurring need, but I am not finding it in JODA.  What I am looking for
is a class that captures the notion of a specific, real-world, time
interval.  That is to say, a class that:
1) Has a specific DateTime field that defines when it started,
2) Has a specific DateTime field that defines when it ended,
3) Implements java.lang.Comparable.

It would be nice if it could also provide:
1) the intelligent grasp of time passage that is in Period,
2) the ability to report its relationship to other "specific intervals",
in much the same way that Joda's Interval class can do with other Intervals.

I can write such a class, based on the current API in JODA, but it seems
that this would be an obvious and highly reusable component, so I am
wondering if I am just missing it in the current API?
If it isn't there already, if I implemented such a class, what would it
take to get it included in future releases?

Possible applications: work-shifts, marriage dates, time
someone/something was at a particular location, career length, political
time in office, beginning/end of wars, previous flights of an air-plane,
time when a component was in service etc.

--
A. Rick Anderson
540-347-0311



------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest



--
A. Rick Anderson
540-347-0311


------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to