Class F_Instant

java.lang.Object
com.ssgllc.fish.f.instant.F_Instant

public class F_Instant extends Object
An absolute moment in time, and the start of every f().instant chain.

Continue through is to compare, elapsed to measure a distance, add or subtract to shift, and toIso() or one of the format overloads to render.

  • Field Details

    • instant

      public Instant instant
      The underlying moment, for handing to Java APIs that want an Instant.
    • is

      public F_Instant_Is is
      Comparisons: f().instant.now().is.after(entity.createdDate).
    • add

      public F_Instant_Add add
      Move forwards: f().instant.now().add.hours(2).
    • subtract

      public F_Instant_Add subtract
      Move backwards: f().instant.now().subtract.days(30).
    • elapsed

      public F_Instant_Elapsed elapsed
      Distance to another moment: f().instant.now().elapsed.minutes.after(start).
  • Constructor Details

    • F_Instant

      public F_Instant(Instant instant)
  • Method Details

    • format

      public String format(String format)
      The moment formatted with a pattern, in the US locale and the system default zone. Use format(String, String, String) to control the zone, which matters whenever the output is shown to a user.
      Parameters:
      format - the format pattern
      Returns:
      the formatted moment

      Groovy example:
      f().instant.now().format("MM/dd/yyyy h:mm a")

      Returns:
      "08/21/2026 9:45 AM"

      SpEL example:
      #f().instant.now().format("MM/dd/yyyy h:mm a")
    • format

      public String format(String format, String locale)
      The moment formatted with a pattern in a given locale, in the system default zone.
      Parameters:
      format - the format pattern
      locale - a BCP 47 locale tag, e.g. "es-US"
      Returns:
      the formatted moment

      Groovy example:
      f().instant.now().format("MMMM d, yyyy", "es-US")

      Returns:
      "agosto 21, 2026"

      SpEL example:
      #f().instant.now().format("MMMM d, yyyy", "es-US")
    • format

      public String format(String format, String locale, String timezone)
      The moment formatted with a pattern, in a given locale and zone. The explicit zone is the reason to prefer this overload for anything a user reads: the same instant is a different wall-clock time in each zone.
      Parameters:
      format - the format pattern
      locale - a BCP 47 locale tag
      timezone - the zone id, e.g. "America/Los_Angeles"
      Returns:
      the formatted moment

      Groovy example:
      f().instant.now().format("h:mm a", "en-US", "America/Los_Angeles")

      Returns:
      "6:45 AM"

      SpEL example:
      #f().instant.now().format("h:mm a", "en-US", "America/Los_Angeles")
    • toIso

      public String toIso()
      The moment as an ISO-8601 instant string in UTC. This is what the value serialises to, and the right form for a payload another system will parse.
      Returns:
      the moment in ISO-8601

      Groovy example:
      f().instant.now().toIso()

      Returns:
      "2026-08-21T13:45:12.335Z"

      SpEL example:
      #f().instant.now().toIso()