This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi, Could you please tell me, how to check a Date as holiday? i.e for example today's date is 03/04/2006. How do i make a check that today is holiday (excluding/including weekend, it's your choice! ).
Java's GregorianCalendar class knows nothing about holidays, since thay are particular to a location, and subject to change. What you could do is create a static data structure containing all the dates which constitute a holiday in whichever location your application is being run (you will have to populate this manually) and check dates against it. For example you could have a HashMap for each year, keyed on Calendar.DAY_OF_YEAR, whose value is a Boolean denoting whether it is a holiday or not.
Originally posted by Biswajit Paria: In other ways, by creating a table in database with holidays list we can do the same thing.
Yes, but for speed you probably want this in memory. A database round trip every time you use a date is a bit of an overhead. If your application reads your table once when it starts up and hold the data in memory you avoid this.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Originally posted by Biswajit Paria: Jeff Albertson , How do you want to feel..?
Yaar, I want to feel that Java will be able to tell me when Diwali starts.