Stephen Colebourne wrote:
The question with DateRange is whether this is a direction that [lang]
should go in. Joda-Time has demonstrated that there are many weird and
strange things to consider when dealing with dates.
Understood. Well, in the meanwhile, it's in Bugzilla until a final
yes/no decision is appropriate. I had a need for the class, but if
[lang] isn't a good fit, then that's obviously fine too.
There were some edge cases that may constitute the weirdness that you
mentioned, like whether or not the range is inclusive (currently yes),
or whether a 0-length range is valid (currently yes). The desire for a
multitude of behaviors by users may be a good reason not to include it,
to avoid having to create a hierarchy like InclusiveDateRange,
NonZeroDateRange, etc.
Thanks for the feedback.
matthew.hawthorne wrote:
I mentioned many moons ago that I had created a DateRange class for
some vicious date mangling that I had to do. I have now modified it
to fit into lang.time, and attached the class + unit test to a bug:
http://issues.apache.org/bugzilla/show_bug.cgi?id=38800
I've been away from the commons scene for awhile, so I may have missed
some protocol-related details. It'd be great if someone could take a
look at what I've done.
Below is a quick API description of what is there. I think that
subtract is a little iffy (although I did have a need for it), but the
rest seems to be fairly simple.
Assuming that my commit rights are still in effect, I could add this
to the codebase myself -- but I wanted to get some feedback to make
sure we were all on the same page.
Thanks!
----------------
DateRange(Date startDate, Date endDate)
equals, compareTo, toString
-- basic stuff
long getTime()
-- endDate.getTime() - startDate.getTime()
boolean contains(Date)
boolean contains(DateRange)
-- true if this range contains the specified Date or DateRange
boolean intersects(DateRange)
-- true if this range intersects with the specified DateRange
DateRange intersection(DateRange)
-- returns a DateRange representing the intersection between this and
the specified range.
List subtract(DateRange)
-- returns one or more DateRanges representing the difference between
the two ranges. If the specified range is larger than this, than the
list is empty (representing a null range). If this contains the
specified range, then the result will have two parts, a range from the
start of this to the start of the specified range, and a range from
the end of the specified range to the end of this.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]