This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Code to check whether a given date falls on weekend or holidays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Code to check whether a given date falls on weekend or holidays" Watch "Code to check whether a given date falls on weekend or holidays" New topic
Author

Code to check whether a given date falls on weekend or holidays

Sonali Sabnis
Greenhorn

Joined: Aug 25, 2008
Posts: 20
Hi,

Can anyone provide a code fragment which will accept a date and check if it falls on weekend or holidays.
If it falls on weekend or holidays then I need to increment that date in order to check again if the new date( incremented) falls on holiday or weekend.

Appriciate yoor help and quick responses.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38474
    
  23
The Calendar classes will return day of week; I hope that's useful for a start.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

As for holidays, you will need to specify what the holidays are. THese are different for each country, and will even be different each year (Easter and such).

If you have such a collection or array of holidays you can compare:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: Code to check whether a given date falls on weekend or holidays