• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to check a date as 'holiday' in java

 
Ranch Hand
Posts: 46
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just found the perfect solution for your problem

here



jan
 
I think I'll just lie down here for a second. And ponder this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic