RBz
RBz

Reputation: 935

Jodatime overlap method not checking equals

For finding the overlap of two date ranges i understand we need something like.

(thisStart <= otherEnd ) && (otherStart <= thisEnd)

But inside the overlaps method from Joda Time I see

thisStart < otherEnd && otherStart < thisEnd

This wont cover certain overlap conditions. Is there any other method which cover overlap using <=

Upvotes: 1

Views: 453

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

start and end designate instants in time. In Joda (and any sane implementation of a time range) a range is half-open on the right, i.e. it does not include the end-instant.

Under those conditions, the test in the Joda library is correct.

If you're still unconvinced, try to come up with a counterexample where overlap is not detected correctly.

Upvotes: 1

Related Questions