How to check if 2 Date Ranges Overlap in Java

Code to check if 2 date ranges overlap each other or not.


/**
* @return boolean true in case the date ranges overlap.
*/
boolean isOverLaped(Date start1,Date end1,Date start2,Date end2) throws NullPointerException{
    if ((start1.before(start2) && end1.after(start2)) || 
		(start1.before(end2) && end1.after(end2)) || 
		(start1.before(start2) && end1.after(end2))) {
        return true;
    } else {
        return false;
    }
}

Advertisements

About Vineet Verma

Developer/Blogger/Gamer/Lazy Couch Potato...:P Need PDF Books: Knowledge Base
This entry was posted in Java and tagged , , . Bookmark the permalink.

8 Responses to How to check if 2 Date Ranges Overlap in Java

  1. Ofelia says:

    Its like you read my mind! You appear to know a lot about this, like you wrote
    the book in it or something. I think that you
    could do with some pics to drive the message home a little bit, but other than that, this is magnificent blog.
    A great read. I’ll certainly be back.

    Like

  2. Cyril says:

    Spot on with this write-up, I really believe this amazing site
    needs much more attention. I’ll probably be
    back again to read through more, thanks for the information!

    Like

  3. Hey! I know this is kinda off topic but I was wondering
    which blog platform are you using for this website?
    I’m getting sick and tired of WordPress because I’ve had issues with hackers and I’m looking at alternatives for another platform.
    I would be awesome if you could point me in the direction of
    a good platform.

    Like

  4. Hey there just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading correctly.
    I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and
    both show the same results.

    Like

  5. This article is in fact a fastidious one it helps new internet people, who are wishing
    for blogging.

    Like

  6. My family always say that I am killing my time here at net, but I know I am getting knowledge all the
    time by reading thes nice articles or reviews.

    Like

  7. Hi there, You have done an excellent job. I will definitely
    digg it and personally suggest to my friends. I’m confident they will be
    benefited from this site.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s