Interface HolidayProvider
public interface HolidayProvider
Interface for providing holiday data
节假日数据提供者接口
This interface defines the contract for providing holiday information. Implementations can provide data from various sources like configuration files, databases, or external APIs.
此接口定义了提供节假日信息的契约。实现可以从配置文件、数据库或外部API等各种来源提供数据。
Features | 主要功能:
- Holiday data retrieval by year - 按年份检索假日数据
- Holiday checking for specific dates - 检查特定日期是否为假日
- Special workday support - 特殊工作日支持
- Country/region identification - 国家/地区标识
Usage Examples | 使用示例:
HolidayProvider provider = new ChinaHolidayProvider();
List<Holiday> holidays = provider.getHolidays(2024);
boolean isHoliday = provider.isHoliday(LocalDate.of(2024, 10, 1));
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: Implementation dependent - 空值安全: 取决于实现
- Since:
- JDK 25, opencode-base-date V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetAdjustedWorkdays(int year) Gets the set of dates that are adjusted workdays (补班日) 获取调休工作日的日期集合(补班日)Gets the country/region code 获取国家/地区代码getHoliday(LocalDate date) Gets the holiday for a specific date 获取指定日期的节假日getHolidays(int year) Gets all holidays for a specific year 获取指定年份的所有节假日getHolidays(LocalDate start, LocalDate end) Gets holidays in a date range 获取日期范围内的节假日getName()Gets the provider name 获取提供者名称int[]Gets the supported year range 获取支持的年份范围booleanisAdjustedWorkday(LocalDate date) Checks if a date is an adjusted workday (补班日) 检查日期是否为调休工作日(补班日)booleanChecks if a date is a holiday 检查日期是否为节假日booleanChecks if a date is a workday 检查日期是否为工作日default booleanisYearSupported(int year) Checks if a year is supported 检查年份是否受支持default voidrefresh()Refreshes the holiday data (if applicable) 刷新节假日数据(如果适用)
-
Method Details
-
getName
-
getCountryCode
String getCountryCode()Gets the country/region code 获取国家/地区代码- Returns:
- the country code (e.g., "CN", "US") | 国家代码(如"CN"、"US")
-
getHolidays
-
getHolidays
-
isHoliday
Checks if a date is a holiday 检查日期是否为节假日- Parameters:
date- the date to check | 要检查的日期- Returns:
- true if it's a holiday | 如果是节假日返回true
-
getHoliday
-
isWorkday
Checks if a date is a workday 检查日期是否为工作日This considers both weekends and holidays.
这同时考虑周末和节假日。
- Parameters:
date- the date to check | 要检查的日期- Returns:
- true if it's a workday | 如果是工作日返回true
-
getAdjustedWorkdays
-
isAdjustedWorkday
Checks if a date is an adjusted workday (补班日) 检查日期是否为调休工作日(补班日)- Parameters:
date- the date to check | 要检查的日期- Returns:
- true if it's an adjusted workday | 如果是调休工作日返回true
-
getSupportedYearRange
int[] getSupportedYearRange()Gets the supported year range 获取支持的年份范围- Returns:
- array of [minYear, maxYear] | [最小年份, 最大年份]数组
-
isYearSupported
default boolean isYearSupported(int year) Checks if a year is supported 检查年份是否受支持- Parameters:
year- the year | 年份- Returns:
- true if supported | 如果支持返回true
-
refresh
default void refresh()Refreshes the holiday data (if applicable) 刷新节假日数据(如果适用)
-