Class F_PlainDate_Add

java.lang.Object
com.ssgllc.fish.f.plaindate.F_PlainDate_Add

public class F_PlainDate_Add extends Object
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 Details

    • F_PlainDate_Add

      public F_PlainDate_Add(LocalDate date, int direction)
  • Method Details

    • days

      public F_PlainDate days(int days)
      Moves the date by a number of days. Reached as add to move forwards or subtract to 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

      public F_PlainDate weeks(int weeks)
      Moves the date by a number of weeks. Reached as add to move forwards or subtract to 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

      public F_PlainDate 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. Reached as add to move forwards or subtract to 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

      public F_PlainDate years(int years)
      Moves the date by a number of years, clamping 29 February to the 28th in a non-leap target year. Reached as add to move forwards or subtract to 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()