Package fr.marcwrobel.jbanking.calendar
Interface Calendar
-
- All Known Implementing Classes:
CompositeCalendar,ConfigurableCalendar,FinancialCalendars
public interface CalendarA calendar that handles date calculations, taking bankHolidays into account. Days that are not bank holidays are called business days.Subclasses of this interface are expected to be thread-safe and immutable.
- Since:
- 2.1.0
- Author:
- Marc Wrobel
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_ITERATIONSMaximum number of iteration for date calculations before giving up.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default List<LocalDate>businessDaysWithin(LocalDate from, LocalDate to)Compute the business days betweenfrom(inclusive) andto(inclusive).Set<Holiday>getHolidaysFor(LocalDate date)Get all theHolidays matching with the given day.default List<LocalDate>holidaysWithin(LocalDate from, LocalDate to)Compute the holidays betweenfrom(inclusive) andto(inclusive).default booleanisBusinessDay(LocalDate date)Check whether the given date is a business day.booleanisHoliday(LocalDate date)Check whether the given date is a public holiday.default LocalDatenext(LocalDate date)Compute the next business day after the given date (excluded).default LocalDatenextOrSame(LocalDate date)Compute the next business day after the given date (included).default LocalDateprevious(LocalDate date)Compute the previous business day before the given date (excluded).default LocalDatepreviousOrSame(LocalDate date)Compute the previous business day before the given date (included).default LocalDateshift(LocalDate date, int numberOfDays)Shifts the given date by the specified number of business days.
-
-
-
Field Detail
-
MAX_ITERATIONS
static final int MAX_ITERATIONS
Maximum number of iteration for date calculations before giving up.- See Also:
- Constant Field Values
-
-
Method Detail
-
isHoliday
boolean isHoliday(LocalDate date)
Check whether the given date is a public holiday.- Parameters:
date- a non-null date.- Returns:
trueif the given date is a holiday,falseotherwise.
-
getHolidaysFor
Set<Holiday> getHolidaysFor(LocalDate date)
Get all theHolidays matching with the given day.- Parameters:
date- a non-null and unmodifiable set ofHolidays.- Returns:
trueif the given date is a holiday,falseotherwise.
-
isBusinessDay
default boolean isBusinessDay(LocalDate date)
Check whether the given date is a business day.- Parameters:
date- a non-null date.- Returns:
trueif the given date is a business day,falseotherwise.
-
shift
default LocalDate shift(LocalDate date, int numberOfDays)
Shifts the given date by the specified number of business days. If the given amount is- zero, the input date is returned,
- positive, later business days are chosen
- negative, earlier business days are chosen
- Parameters:
date- the date to shiftnumberOfDays- the number of business days to adjust by- Returns:
- a non-null date
- Throws:
DateCalculationException- if no business day could be found in a reasonable time
-
previous
default LocalDate previous(LocalDate date)
Compute the previous business day before the given date (excluded).- Parameters:
date- a non-null date- Returns:
- a non-null date
- Throws:
DateCalculationException- if no business day could be found in a reasonable time
-
previousOrSame
default LocalDate previousOrSame(LocalDate date)
Compute the previous business day before the given date (included).- Parameters:
date- a non-null date- Returns:
- a non-null date
- Throws:
DateCalculationException- if no business day could be found in a reasonable time
-
next
default LocalDate next(LocalDate date)
Compute the next business day after the given date (excluded).- Parameters:
date- a non-null date- Returns:
- a non-null date
- Throws:
DateCalculationException- if no business day could be found in a reasonable time
-
nextOrSame
default LocalDate nextOrSame(LocalDate date)
Compute the next business day after the given date (included).- Parameters:
date- a non-null date- Returns:
- a non-null date
- Throws:
DateCalculationException- if no business day could be found in a reasonable time
-
holidaysWithin
default List<LocalDate> holidaysWithin(LocalDate from, LocalDate to)
Compute the holidays betweenfrom(inclusive) andto(inclusive).- Parameters:
from- a non-null dateto- a non-null date- Returns:
- a non-null and unmodifiable ordered list of dates
- Throws:
IllegalArgumentException- iffromis afterto
-
businessDaysWithin
default List<LocalDate> businessDaysWithin(LocalDate from, LocalDate to)
Compute the business days betweenfrom(inclusive) andto(inclusive).- Parameters:
from- a non-null dateto- a non-null date- Returns:
- a non-null and unmodifiable ordered list of dates
- Throws:
IllegalArgumentException- iffromis afterto
-
-