Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Range Compare:Overlaps

 
ck Primm
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a beginner at comparing and manipulating dates. I need to compare one date range to another and check for overlapping ranges. If overlapping, I need to flag as an error. I can do this with logic and various compares - but is there an easier way using jave dateRange?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't see anything in the JavaDoc about DateRange. Do you have such a class around?

I think you'll have to do this the hard way: if rangeA start is in rangeB or if rangeA end is in rangeB then overlap is true.

What if you made a DateRange class with signatures like this:

Can you imagine what the constructor and other methods do?
 
Barend Garvelink
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the Joda-Time library. It fixes most of the deficiencies in the Java date/time API.
http://joda-time.sourceforge.net/index.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic