File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Date Range Compare:Overlaps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date Range Compare:Overlaps" Watch "Date Range Compare:Overlaps" New topic
Author

Date Range Compare:Overlaps

ck Primm
Greenhorn

Joined: Jul 25, 2005
Posts: 1
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

Joined: Jan 29, 2003
Posts: 8791
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?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Barend Garvelink
Ranch Hand

Joined: Dec 07, 2004
Posts: 64
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


SCJP 1.4, SCJD 1.4, SCWCD 1.3, ICSD:Websphere 5.1
 
jQuery in Action, 2nd edition
 
subject: Date Range Compare:Overlaps
 
Similar Threads
comparing dates in db2
Hibernate comparing columns
overlapping dates
is that any utility class that help compare date within start and end date ?
Date Range check