Class DayOfWeekInMonthHoliday

java.lang.Object
fr.marcwrobel.jbanking.calendar.DayOfWeekInMonthHoliday
All Implemented Interfaces:
Holiday

public final class DayOfWeekInMonthHoliday extends Object implements Holiday
A Holiday occurring the same day of the week in a month every year.

This class is using TemporalAdjusters.dayOfWeekInMonth(int, DayOfWeek) under the hood.

This class is useful for modeling holidays like Martin Luther King Jr. Day.

Since:
2.1.0
See Also:
  • Constructor Details

    • DayOfWeekInMonthHoliday

      public DayOfWeekInMonthHoliday(int weekNumber, DayOfWeek dayOfWeek, Month month)
      Create a new holiday using the given DayOfWeek and Month
      Parameters:
      weekNumber - the week within the month, unbounded but typically from -5 to 5
      dayOfWeek - a non-null DayOfWeek
      month - a non-null Month
      Throws:
      NullPointerException - if the given MonthDay is null
  • Method Details

    • check

      public boolean check(LocalDate date)
      Description copied from interface: Holiday
      Check whether the given date is an occurrence of this holiday.
      Specified by:
      check in interface Holiday
      Parameters:
      date - the date to check.
      Returns:
      true if the given date is an occurrence of this holiday, false otherwise.
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object