Class ChinaHolidayEvent
java.lang.Object
cloud.opencode.base.date.holiday.ChinaHolidayEvent
- All Implemented Interfaces:
Serializable
A Chinese State-Council-issued holiday event with closed-interval ranges.
国务院发布的中国节假日事件,由闭区间日期段组成。
Each notice from the State Council typically defines:
国务院每次发布的节假日通知通常包含:
- One or more holiday closed-interval ranges (e.g., 2026-05-01 to 2026-05-05) - 一个或多个放假闭区间(例如:2026-05-01 至 2026-05-05)
- Zero or more makeup-workday closed-interval ranges where weekends become workdays (e.g., 2026-05-09 to 2026-05-09) - 零个或多个补班闭区间(周末调班为工作日,例如:2026-05-09 至 2026-05-09)
Both range endpoints are inclusive. Multiple ranges are supported because some Council notices split a holiday into non-contiguous spans, and makeup days frequently fall on multiple weekends bracketing the holiday.
两端均为闭区间。支持多段区间,因为部分通知将假期切分为不连续段,补班日也常分布在假期前后的多个周末。
Usage Examples | 使用示例:
// 2026 Labor Day: 5/1-5/5 holiday, 5/9 (Sat) makeup workday
ChinaHolidayEvent laborDay = ChinaHolidayEvent.builder()
.name("Labor Day")
.chineseName("劳动节")
.addHolidayRange(LocalDate.of(2026, 5, 1), LocalDate.of(2026, 5, 5))
.addMakeupWorkdayRange(LocalDate.of(2026, 5, 9), LocalDate.of(2026, 5, 9))
.build();
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Null-safe: Yes (with explicit null checks in builder) - 空值安全: 是(构建器中有明确的空值检查)
- Since:
- JDK 25, opencode-base-date V1.0.4
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ChinaHolidayEvent.Builderbuilder()Creates a builder.booleanGets the holiday closed-interval ranges (放假闭区间).Gets the makeup-workday closed-interval ranges (补班闭区间).getName()inthashCode()booleanReturns true if the date falls in any holiday range.booleanisMakeupWorkday(LocalDate date) Returns true if the date falls in any makeup-workday range.static ChinaHolidayEventConvenience factory for an event with a single holiday range and no makeup days.toString()
-
Method Details
-
builder
Creates a builder. 创建构建器。- Returns:
- a new builder | 新构建器
-
of
Convenience factory for an event with a single holiday range and no makeup days. 单个放假区间且无补班日期的便捷工厂方法。- Parameters:
name- English name | 英文名称chineseName- Chinese name (nullable) | 中文名称(可为 null)start- holiday start (inclusive) | 放假开始日期(包含)end- holiday end (inclusive) | 放假结束日期(包含)- Returns:
- the event | 事件
-
getName
-
getChineseName
-
getHolidayRanges
Gets the holiday closed-interval ranges (放假闭区间). 获取放假闭区间列表。- Returns:
- immutable list | 不可变列表
-
getMakeupWorkdayRanges
Gets the makeup-workday closed-interval ranges (补班闭区间). 获取补班闭区间列表。- Returns:
- immutable list | 不可变列表
-
isHoliday
Returns true if the date falls in any holiday range. 当日期落在任一放假区间内时返回 true。- Parameters:
date- the date | 日期- Returns:
- true if in a holiday range | 在放假区间内时返回 true
-
isMakeupWorkday
Returns true if the date falls in any makeup-workday range. 当日期落在任一补班区间内时返回 true。- Parameters:
date- the date | 日期- Returns:
- true if in a makeup-workday range | 在补班区间内时返回 true
-
equals
-
hashCode
-
toString
-