Class DateAdjusters
java.lang.Object
cloud.opencode.base.date.adjuster.DateAdjusters
Extended temporal adjusters for common date operations
扩展的时间调整器,用于常见日期操作
This class provides additional temporal adjusters beyond those in java.time.temporal.TemporalAdjusters, focused on business and common use cases.
此类提供比java.time.temporal.TemporalAdjusters更多的时间调整器, 专注于业务和常见用例。
Features | 主要功能:
- Start/end of year, quarter, month, week - 年、季、月、周的开始/结束
- Next/previous occurrence adjusters - 下一个/上一个发生调整器
- Nth occurrence adjusters - 第N次发生调整器
- Business day adjusters - 工作日调整器
Usage Examples | 使用示例:
LocalDate date = LocalDate.of(2024, 6, 15);
// Start of quarter
LocalDate startOfQ = date.with(DateAdjusters.startOfQuarter());
// 2024-04-01
// End of quarter
LocalDate endOfQ = date.with(DateAdjusters.endOfQuarter());
// 2024-06-30
// Next Monday
LocalDate nextMon = date.with(DateAdjusters.nextOrSame(DayOfWeek.MONDAY));
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: No (callers must provide non-null arguments) - 空值安全: 否(调用者必须提供非空参数)
- Since:
- JDK 25, opencode-base-date V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic TemporalAdjusterdayOfMonth(int day) Returns the nth day of the month adjuster 返回月份第N天调整器static TemporalAdjusterReturns the end of the first half of the year 返回上半年结束static TemporalAdjusterReturns the end of the month adjuster (alias for lastDayOfMonth) 返回月末调整器(lastDayOfMonth的别名)static TemporalAdjusterReturns the end of the current quarter adjuster 返回当前季度结束调整器static TemporalAdjusterReturns the end of the second half of the year 返回下半年结束static TemporalAdjusterReturns the end of the week adjuster (Sunday) 返回周末调整器(周日)static TemporalAdjusterReturns the end of the week adjuster for a specific last day 返回特定末日的周末调整器static TemporalAdjusterReturns the end of the year adjuster 返回年末调整器static TemporalAdjusterminus(long amount, ChronoUnit unit) Returns an adjuster that subtracts the specified number of units 返回减去指定数量单位的调整器static TemporalAdjusterReturns an adjuster to the nearest weekday 返回最近工作日的调整器static TemporalAdjusterReturns an adjuster for the next occurrence of a day of week (strictly after) 返回下一个星期几的调整器(严格之后)static TemporalAdjusternextMonthDay(Month month, int day) Returns an adjuster to the next occurrence of a specific month and day 返回下一个特定月日的调整器static TemporalAdjusternextOrSame(DayOfWeek dayOfWeek) Returns an adjuster for the next or same occurrence of a day of week 返回下一个或相同星期几的调整器static TemporalAdjusternthDayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek) Returns the nth weekday of the month adjuster 返回月份第N个工作日调整器static TemporalAdjusterplus(long amount, ChronoUnit unit) Returns an adjuster that adds the specified number of units 返回添加指定数量单位的调整器static TemporalAdjusterplusBusinessDays(int days) Returns an adjuster for adding/subtracting business days 返回添加/减去工作日的调整器static TemporalAdjusterReturns an adjuster for the previous occurrence of a day of week (strictly before) 返回上一个星期几的调整器(严格之前)static TemporalAdjusterpreviousOrSame(DayOfWeek dayOfWeek) Returns an adjuster for the previous or same occurrence of a day of week 返回上一个或相同星期几的调整器static TemporalAdjusterReturns the start of the first half of the year 返回上半年开始static TemporalAdjusterReturns the start of the month adjuster (alias for firstDayOfMonth) 返回月初调整器(firstDayOfMonth的别名)static TemporalAdjusterReturns the start of the current quarter adjuster 返回当前季度开始调整器static TemporalAdjusterstartOfQuarter(int quarter) Returns the start of a specific quarter adjuster 返回特定季度开始调整器static TemporalAdjusterReturns the start of the second half of the year 返回下半年开始static TemporalAdjusterReturns the start of the week adjuster (Monday) 返回周初调整器(周一)static TemporalAdjusterstartOfWeek(DayOfWeek firstDayOfWeek) Returns the start of the week adjuster for a specific first day 返回特定首日的周初调整器static TemporalAdjusterReturns the start of the year adjuster 返回年初调整器
-
Method Details
-
startOfYear
Returns the start of the year adjuster 返回年初调整器- Returns:
- the adjuster | 调整器
-
endOfYear
Returns the end of the year adjuster 返回年末调整器- Returns:
- the adjuster | 调整器
-
startOfQuarter
Returns the start of the current quarter adjuster 返回当前季度开始调整器- Returns:
- the adjuster | 调整器
-
endOfQuarter
Returns the end of the current quarter adjuster 返回当前季度结束调整器- Returns:
- the adjuster | 调整器
-
startOfQuarter
Returns the start of a specific quarter adjuster 返回特定季度开始调整器- Parameters:
quarter- the quarter (1-4) | 季度(1-4)- Returns:
- the adjuster | 调整器
-
startOfMonth
Returns the start of the month adjuster (alias for firstDayOfMonth) 返回月初调整器(firstDayOfMonth的别名)- Returns:
- the adjuster | 调整器
-
endOfMonth
Returns the end of the month adjuster (alias for lastDayOfMonth) 返回月末调整器(lastDayOfMonth的别名)- Returns:
- the adjuster | 调整器
-
startOfWeek
Returns the start of the week adjuster (Monday) 返回周初调整器(周一)- Returns:
- the adjuster | 调整器
-
startOfWeek
Returns the start of the week adjuster for a specific first day 返回特定首日的周初调整器- Parameters:
firstDayOfWeek- the first day of week | 一周的第一天- Returns:
- the adjuster | 调整器
-
endOfWeek
Returns the end of the week adjuster (Sunday) 返回周末调整器(周日)- Returns:
- the adjuster | 调整器
-
endOfWeek
Returns the end of the week adjuster for a specific last day 返回特定末日的周末调整器- Parameters:
lastDayOfWeek- the last day of week | 一周的最后一天- Returns:
- the adjuster | 调整器
-
dayOfMonth
Returns the nth day of the month adjuster 返回月份第N天调整器- Parameters:
day- the day of month | 月份的日期- Returns:
- the adjuster | 调整器
-
nthDayOfWeekInMonth
Returns the nth weekday of the month adjuster 返回月份第N个工作日调整器- Parameters:
ordinal- the ordinal (1-5, or -1 for last) | 序数(1-5,或-1表示最后)dayOfWeek- the day of week | 周几- Returns:
- the adjuster | 调整器
-
nextOrSame
Returns an adjuster for the next or same occurrence of a day of week 返回下一个或相同星期几的调整器- Parameters:
dayOfWeek- the day of week | 星期几- Returns:
- the adjuster | 调整器
-
previousOrSame
Returns an adjuster for the previous or same occurrence of a day of week 返回上一个或相同星期几的调整器- Parameters:
dayOfWeek- the day of week | 星期几- Returns:
- the adjuster | 调整器
-
next
Returns an adjuster for the next occurrence of a day of week (strictly after) 返回下一个星期几的调整器(严格之后)- Parameters:
dayOfWeek- the day of week | 星期几- Returns:
- the adjuster | 调整器
-
previous
Returns an adjuster for the previous occurrence of a day of week (strictly before) 返回上一个星期几的调整器(严格之前)- Parameters:
dayOfWeek- the day of week | 星期几- Returns:
- the adjuster | 调整器
-
startOfFirstHalf
Returns the start of the first half of the year 返回上半年开始- Returns:
- the adjuster | 调整器
-
endOfFirstHalf
Returns the end of the first half of the year 返回上半年结束- Returns:
- the adjuster | 调整器
-
startOfSecondHalf
Returns the start of the second half of the year 返回下半年开始- Returns:
- the adjuster | 调整器
-
endOfSecondHalf
Returns the end of the second half of the year 返回下半年结束- Returns:
- the adjuster | 调整器
-
nextMonthDay
Returns an adjuster to the next occurrence of a specific month and day 返回下一个特定月日的调整器- Parameters:
month- the month | 月份day- the day of month | 日期- Returns:
- the adjuster | 调整器
-
plusBusinessDays
Returns an adjuster for adding/subtracting business days 返回添加/减去工作日的调整器- Parameters:
days- the number of business days (can be negative) | 工作日数(可为负)- Returns:
- the adjuster | 调整器
-
nearestWeekday
Returns an adjuster to the nearest weekday 返回最近工作日的调整器- Returns:
- the adjuster | 调整器
-
plus
Returns an adjuster that adds the specified number of units 返回添加指定数量单位的调整器- Parameters:
amount- the amount to add | 要添加的数量unit- the unit | 单位- Returns:
- the adjuster | 调整器
-
minus
Returns an adjuster that subtracts the specified number of units 返回减去指定数量单位的调整器- Parameters:
amount- the amount to subtract | 要减去的数量unit- the unit | 单位- Returns:
- the adjuster | 调整器
-