com.mindprod.holidays
Class IsHoliday

java.lang.Object
  extended by com.mindprod.holidays.IsHoliday

public final class IsHoliday
extends java.lang.Object

Find out if there is any holiday/celebration on a given date.

Lets you easily define a set of holidays, then rapidly determine if any given date is a holiday. It is quite easy to specify which days you want considered holidays using methods like addHoliday where you specify the date or the name of the Holiday, addAmericanFederalHolidays and addWeekDaysAsHolidays.

Since:
1999
Version:
4.2 2008-12-03 add World AIDS day
Author:
Roedy Green, Canadian Mind Products

Field Summary
protected  int firstOrd
          ordinal of Jan 1 of first year to compute holidays.
protected  int firstYear
          First year in range to compute holidays.
protected  java.util.BitSet holidayBits
          corresponding bit is true means day is a holiday.
protected  int lastOrd
          ordinal of Dec 31 of last year to compute holidays.
protected  int lastYear
          Last year in range to compute holidays.
 
Constructor Summary
IsHoliday(int firstYear, int lastYear)
          Constructor to define range of years over which we wish to compute holidays.
 
Method Summary
 void addAmericanFederalHolidays(boolean shift)
          add all American Federal holidays To get a list of US Federal Statutory holidays see: http://www.opm.gov/fedhol/1999.htm or http://aa.usno.navy.mil/AA/faq/docs/holidays.html.
 void addCanadianFederalHolidays(boolean shift)
          add all Canadian Federal holidays To get a list of US Federal Statutory holidays see: http://www.opm.gov/fedhol/1999.htm or http://aa.usno.navy.mil/AA/faq/docs/holidays.html.
 void addHoliday(int ordinal)
          add another holiday to the holiday table.
 void addWeekendsAsHolidays()
          add all Saturdays and Sundays in the year range as holidays
 int getFirstYear()
          get first year in range to compute the holidays.
 int getLastYear()
          Get last year in range to compute holidays.
 boolean isHoliday(com.mindprod.common11.BigDate bigDate)
          Is the given day a holiday? What constitutes a holiday is determined by the setHoliday calls
 boolean isHoliday(int ordinal)
          Is the given day a holiday? What constitutes a holiday is determined by the setHoliday calls
static void main(java.lang.String[] args)
          test driver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstOrd

protected int firstOrd
ordinal of Jan 1 of first year to compute holidays.


firstYear

protected int firstYear
First year in range to compute holidays.


lastOrd

protected int lastOrd
ordinal of Dec 31 of last year to compute holidays.


lastYear

protected int lastYear
Last year in range to compute holidays.


holidayBits

protected java.util.BitSet holidayBits
corresponding bit is true means day is a holiday.

Constructor Detail

IsHoliday

public IsHoliday(int firstYear,
                 int lastYear)
Constructor to define range of years over which we wish to compute holidays.

Parameters:
firstYear - first year to cover, must be > 0
lastYear - last year to cover
Method Detail

addAmericanFederalHolidays

public void addAmericanFederalHolidays(boolean shift)
add all American Federal holidays To get a list of US Federal Statutory holidays see: http://www.opm.gov/fedhol/1999.htm or http://aa.usno.navy.mil/AA/faq/docs/holidays.html.

Parameters:
shift - shift ACTUAL = false if you want the actual date of the holiday. SHIFTED = true if you want the date taken off work, usually the nearest weekday.

addCanadianFederalHolidays

public void addCanadianFederalHolidays(boolean shift)
add all Canadian Federal holidays To get a list of US Federal Statutory holidays see: http://www.opm.gov/fedhol/1999.htm or http://aa.usno.navy.mil/AA/faq/docs/holidays.html.

Parameters:
shift - shift ACTUAL = false if you want the actual date of the holiday. SHIFTED = true if you want the date taken off work, usually the nearest weekday.

addHoliday

public void addHoliday(int ordinal)
add another holiday to the holiday table.

Parameters:
ordinal - day to add as a holiday measured in days since 1970-01-01. Note you must add it once for each year in the range. We do not presume it falls the same day each year.

addWeekendsAsHolidays

public void addWeekendsAsHolidays()
add all Saturdays and Sundays in the year range as holidays


getFirstYear

public int getFirstYear()
get first year in range to compute the holidays.

Returns:
year yyyy.

getLastYear

public int getLastYear()
Get last year in range to compute holidays.

Returns:
year YYYY.

isHoliday

public boolean isHoliday(com.mindprod.common11.BigDate bigDate)
Is the given day a holiday? What constitutes a holiday is determined by the setHoliday calls

Parameters:
bigDate - date to test
Returns:
true if that day is a holiday

isHoliday

public boolean isHoliday(int ordinal)
Is the given day a holiday? What constitutes a holiday is determined by the setHoliday calls

Parameters:
ordinal - days since 1970-01-01
Returns:
true if that day is a holiday.

main

public static void main(java.lang.String[] args)
test driver

Parameters:
args - not used