@FunctionalInterface public interface HolidayModel extends ChronoCondition<PlainDate>
Represents a rule how to find a non-business day.
DateInterval.streamExcluding(Predicate)| Modifier and Type | Method and Description |
|---|---|
default IsoDateUnit |
businessDays()
Creates a special time unit for the counting of business days.
|
default ChronoFunction<ChronoInterval<PlainDate>,Integer> |
countOfBusinessDays()
Queries the count of business days in an arbitrary date interval.
|
default ChronoFunction<ChronoInterval<PlainDate>,Integer> |
countOfHolidays()
Queries the count of non-business days in an arbitrary date interval.
|
default ChronoFunction<ChronoInterval<PlainDate>,PlainDate> |
firstBusinessDay()
Queries the first business day in an arbitrary date interval.
|
default ChronoCondition<PlainDate> |
firstBusinessDayInMonth()
Queries if a given date is the first business day of month.
|
default boolean |
isBusinessDay(PlainDate date)
Queries if given date is a business day.
|
default ChronoFunction<ChronoInterval<PlainDate>,PlainDate> |
lastBusinessDay()
Queries the last business day in an arbitrary date interval.
|
default ChronoCondition<PlainDate> |
lastBusinessDayInMonth()
Queries if a given date is the last business day of month.
|
default ChronoOperator<PlainDate> |
nextBusinessDay()
Determines the next business day.
|
default ChronoOperator<PlainDate> |
nextOrSameBusinessDay()
Determines the same or next business day.
|
static HolidayModel |
ofSaturdayOrSunday()
Determines Saturday and Sunday as non-business days.
|
static HolidayModel |
ofWeekend(Locale country)
Determines a country-specific weekend as non-business days.
|
default ChronoOperator<PlainDate> |
previousBusinessDay()
Determines the previous business day.
|
default ChronoOperator<PlainDate> |
previousOrSameBusinessDay()
Determines the same or previous business day.
|
boolean |
test(PlainDate date)
Queries if given date is a non-business day.
|
boolean test(PlainDate date)
Queries if given date is a non-business day.
default boolean isBusinessDay(PlainDate date)
Queries if given date is a business day.
Equivalent to !test(date).
date - the calendar date to be queriedtrue if the date is a business day else false (holiday or weekend)static HolidayModel ofSaturdayOrSunday()
Determines Saturday and Sunday as non-business days.
static HolidayModel ofWeekend(Locale country)
Determines a country-specific weekend as non-business days.
country - locale with country informationWeekmodel.weekend()default ChronoOperator<PlainDate> nextBusinessDay()
Determines the next business day.
Example skipping a weekend:
PlainDate date = PlainDate.of(2017, 2, 3); // Friday
date = date.with(HolidayModel.ofSaturdayOrSunday().nextBusinessDay());
System.out.println(date); // 2017-02-06 (Monday)
nextOrSameBusinessDay(),
previousOrSameBusinessDay(),
previousBusinessDay()default ChronoOperator<PlainDate> nextOrSameBusinessDay()
Determines the same or next business day.
nextBusinessDay(),
previousBusinessDay(),
previousOrSameBusinessDay()default ChronoOperator<PlainDate> previousBusinessDay()
Determines the previous business day.
nextBusinessDay(),
nextOrSameBusinessDay(),
previousOrSameBusinessDay()default ChronoOperator<PlainDate> previousOrSameBusinessDay()
Determines the same or previous business day.
nextBusinessDay(),
nextOrSameBusinessDay(),
previousBusinessDay()default ChronoFunction<ChronoInterval<PlainDate>,PlainDate> firstBusinessDay()
Queries the first business day in an arbitrary date interval.
null if the first business day does not exist
or throws an exception if applied on an infinite intervalIsoInterval.get(ChronoFunction),
lastBusinessDay()default ChronoFunction<ChronoInterval<PlainDate>,PlainDate> lastBusinessDay()
Queries the last business day in an arbitrary date interval.
Following example shows the last Friday in a month:
PlainDate date = CalendarMonth.of(2017, 4).get(HolidayModel.ofSaturdayOrSunday().lastBusinessDay());
System.out.println(date); // 2017-04-28 (Friday)
null if the last business day does not exist
or throws an exception if applied on an infinite intervalIsoInterval.get(ChronoFunction),
firstBusinessDay()default ChronoFunction<ChronoInterval<PlainDate>,Integer> countOfBusinessDays()
Queries the count of business days in an arbitrary date interval.
Example:
int count = CalendarMonth.of(2017, 1).get(HolidayModel.ofSaturdayOrSunday().countOfBusinessDays()); // 22
IsoInterval.get(ChronoFunction)default ChronoFunction<ChronoInterval<PlainDate>,Integer> countOfHolidays()
Queries the count of non-business days in an arbitrary date interval.
IsoInterval.get(ChronoFunction)default ChronoCondition<PlainDate> firstBusinessDayInMonth()
Queries if a given date is the first business day of month.
ChronoEntity.matches(ChronoCondition),
lastBusinessDayInMonth()default ChronoCondition<PlainDate> lastBusinessDayInMonth()
Queries if a given date is the last business day of month.
Example:
PlainDate date = PlainDate.of(2017, 4, 28);
System.out.println(date.matches(HolidayModel.ofSaturdayOrSunday().lastBusinessDayInMonth()));
// true
ChronoEntity.matches(ChronoCondition),
firstBusinessDayInMonth()default IsoDateUnit businessDays()
Creates a special time unit for the counting of business days.
Only applicable on the types PlainDate and PlainTimestamp.
Copyright © 2014–2021. All rights reserved.