- All Known Implementing Classes:
EarlyCloseHoliday,FixedHoliday,FloatingHoliday,SpecialAnniversary
public sealed interface Holiday
permits FixedHoliday, FloatingHoliday, SpecialAnniversary, EarlyCloseHoliday
An official day on which work does not occur. A holiday may be traditional,
religious, or governmental in origin. Its date of occurrence may be fixed,
moveable, or
otherwise computed.
Permitted subtypes determine the method of holiday date calculation:
FixedHoliday— sameMonthDayevery yearFloatingHoliday— date computed per year via anObservanceSpecialAnniversary— anniversary of a fixedLocalDateEarlyCloseHoliday— a non-rollable partial trading day (since 2.0.0); excluded fromHolidayCalendar.calculate(int)and reported separately byHolidayCalendar.calculateEarlyCloses(int)
Code that exhaustively switches over these subtypes (e.g. switch (holiday) {
case FixedHoliday f -> ...; case FloatingHoliday f -> ...; case SpecialAnniversary s -> ...;
case EarlyCloseHoliday e -> ...; }) must be updated to add the EarlyCloseHoliday
case when upgrading from a pre-2.0.0 release. If the switch is used as an expression
over a nullable Holiday reference, also add an explicit case null branch.
- Author:
- Dave Joyce
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Holiday.HolidayBuilderbuilder()Get a new builder object for construction of a configuredHolidayinstance to be used with one or more holiday calendars.dateForYear(int year) Calculate the date of this holiday for the specified year.Get the description (if any) of this holiday.getName()Get the name of this holiday.booleanDetermine if this holiday supports date rolling for actual observance on a holiday calendar.
-
Method Details
-
builder
Get a new builder object for construction of a configuredHolidayinstance to be used with one or more holiday calendars.- Returns:
- new
Holidaybuilder instance
-
getName
String getName()Get the name of this holiday.- Returns:
- holiday name
-
getDescription
String getDescription()Get the description (if any) of this holiday.- Returns:
- holiday description
-
isRollable
boolean isRollable()Determine if this holiday supports date rolling for actual observance on a holiday calendar.- Returns:
trueif the date of occurrence for this holiday may be rolled for observance,falseotherwise
-
dateForYear
Calculate the date of this holiday for the specified year. The date returned by this method may be adjusted to a different date of observance by the associatedholiday calendar.- Parameters:
year- full calendar year (e.g. 1977, 2021)- Returns:
- date of this holiday, or
emptyif not observed on the specified year
-