Class Holiday
java.lang.Object
cloud.opencode.base.date.holiday.Holiday
- All Implemented Interfaces:
Serializable, Comparable<Holiday>
Represents a holiday with date and metadata
表示带有日期和元数据的假日
This class represents a single holiday with its date, name, type, and additional information.
此类表示单个假日,包含其日期、名称、类型和附加信息。
Features | 主要功能:
- Holiday date and name - 假日日期和名称
- Holiday type classification - 假日类型分类
- Observed date support - 调休日期支持
- Multi-language support - 多语言支持
Usage Examples | 使用示例:
Holiday newYear = Holiday.of(
LocalDate.of(2024, 1, 1),
"New Year's Day",
HolidayType.PUBLIC
);
Holiday springFestival = Holiday.builder()
.date(LocalDate.of(2024, 2, 10))
.name("Spring Festival")
.chineseName("春节")
.type(HolidayType.PUBLIC)
.build();
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Null-safe: Yes (with explicit null checks in builder) - 空值安全: 是(构建器中有明确的空值检查)
- Since:
- JDK 25, opencode-base-date V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for Holiday Holiday构建器static enumTypes of holidays 假日类型 -
Method Summary
Modifier and TypeMethodDescriptionstatic Holiday.Builderbuilder()Creates a builder 创建构建器intbooleanGets the Chinese name 获取中文名称getDate()Gets the date 获取日期Gets the description 获取描述getLocalizedName(boolean preferChinese) Gets the localized name 获取本地化名称getName()Gets the name 获取名称Gets the observed date 获取调休日期getType()Gets the type 获取类型intgetYear()Gets the year of the holiday 获取假日的年份inthashCode()booleanisDayOff()Checks if this is a day off 检查是否放假booleanChecks if the holiday falls on the specified date 检查假日是否在指定日期booleanChecks if this is a public holiday 检查是否为公共假日static HolidayCreates a simple holiday 创建简单假日static Holidayof(LocalDate date, String name, Holiday.HolidayType type) Creates a holiday with type 创建带类型的假日static Holidayof(LocalDate date, String name, String chineseName, Holiday.HolidayType type) Creates a holiday with bilingual names 创建双语名称的假日toString()
-
Method Details
-
of
-
of
Creates a holiday with type 创建带类型的假日- Parameters:
date- the date | 日期name- the name | 名称type- the type | 类型- Returns:
- the Holiday | 假日
-
of
Creates a holiday with bilingual names 创建双语名称的假日- Parameters:
date- the date | 日期name- the English name | 英文名称chineseName- the Chinese name | 中文名称type- the type | 类型- Returns:
- the Holiday | 假日
-
builder
-
getDate
-
getName
-
getChineseName
Gets the Chinese name 获取中文名称- Returns:
- the Chinese name, or null if not set | 中文名称,如果未设置则为null
-
getLocalizedName
Gets the localized name 获取本地化名称- Parameters:
preferChinese- whether to prefer Chinese | 是否偏好中文- Returns:
- the localized name | 本地化名称
-
getType
-
getObservedDate
Gets the observed date 获取调休日期- Returns:
- the observed date, or the actual date if not set | 调休日期,如果未设置则返回实际日期
-
isDayOff
public boolean isDayOff()Checks if this is a day off 检查是否放假- Returns:
- true if day off | 如果放假返回true
-
getDescription
Gets the description 获取描述- Returns:
- the description, or null if not set | 描述,如果未设置则为null
-
isOn
Checks if the holiday falls on the specified date 检查假日是否在指定日期- Parameters:
date- the date to check | 要检查的日期- Returns:
- true if on this date | 如果在此日期返回true
-
isPublicHoliday
public boolean isPublicHoliday()Checks if this is a public holiday 检查是否为公共假日- Returns:
- true if public holiday | 如果是公共假日返回true
-
getYear
public int getYear()Gets the year of the holiday 获取假日的年份- Returns:
- the year | 年份
-
compareTo
- Specified by:
compareToin interfaceComparable<Holiday>
-
equals
-
hashCode
-
toString
-