Package com.ssgllc.fish.f.plaindate
Class F_PlainDate_Add
java.lang.Object
com.ssgllc.fish.f.plaindate.F_PlainDate_Add
Date arithmetic, reached as
add or subtract on an F_PlainDate.
The direction comes from which field you went through, so counts stay positive:
f().date.today().subtract.days(7) rather than adding minus seven.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondays(int days) Moves the date by a number of days.months(int months) Moves the date by a number of months, clamping the day to the target month's length so 31 January plus one month is the end of February.weeks(int weeks) Moves the date by a number of weeks.years(int years) Moves the date by a number of years, clamping 29 February to the 28th in a non-leap target year.
-
Constructor Details
-
F_PlainDate_Add
-
-
Method Details
-
days
Moves the date by a number of days. Reached asaddto move forwards orsubtractto move backwards, so the count is always positive.- Parameters:
days- the number of days to move- Returns:
- the shifted date, to continue the chain from
Groovy example:
f().date.today().add.days(30).toIso()
Returns:
"2026-09-20"
SpEL example:
#f().date.today().add.days(30).toIso()
-
weeks
Moves the date by a number of weeks. Reached asaddto move forwards orsubtractto move backwards, so the count is always positive.- Parameters:
weeks- the number of weeks to move- Returns:
- the shifted date, to continue the chain from
Groovy example:
f().date.today().subtract.weeks(2).toIso()
Returns:
"2026-08-07"
SpEL example:
#f().date.today().subtract.weeks(2).toIso()
-
months
Moves the date by a number of months, clamping the day to the target month's length so 31 January plus one month is the end of February. Reached asaddto move forwards orsubtractto move backwards, so the count is always positive.- Parameters:
months- the number of months to move- Returns:
- the shifted date, to continue the chain from
Groovy example:
f().date.of("2026-01-31").add.months(1).toIso()
Returns:
"2026-02-28"
SpEL example:
#f().date.of("2026-01-31").add.months(1).toIso()
-
years
Moves the date by a number of years, clamping 29 February to the 28th in a non-leap target year. Reached asaddto move forwards orsubtractto move backwards, so the count is always positive.- Parameters:
years- the number of years to move- Returns:
- the shifted date, to continue the chain from
Groovy example:
f().date.of(entity.birthDate).add.years(18).toIso()
Returns:
the eighteenth birthday
SpEL example:
#f().date.of(entity.birthDate).add.years(18).toIso()
-