• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check a date as 'holiday' in java  RSS feed

 
Biswajit Paria
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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! ).

Thanks,
Biswajit
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Biswajit Paria:
Hi,
Could you please tell me, how to check a Date as holiday?


You mean like Diwali?
 
Biswajit Paria
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul Sturrock for your nice suggestion.
In other ways, by creating a table in database with holidays list we can do the same thing.


Jeff Albertson ,
How do you want to feel..?


Thanks,
B
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just found the perfect solution for your problem

here



jan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!