Class PlainTimeBuilder

java.lang.Object
com.ssgllc.fish.f.plaintime.PlainTimeBuilder

public class PlainTimeBuilder extends Object
Builds a time of day to start an f().time chain.

Reached as a field: f().time. A time here carries no date and no zone.

The overloads mirror the front end's f().time, so an expression reads the same on both sides: a string ("14:30" or "2:30pm"), hour and minute with an optional meridiem, or a map of hour / minute / amPm. amPm is "am", "pm" or "mil" and defaults to "mil", meaning the hour is already 24-hour.

  • Constructor Details

    • PlainTimeBuilder

      public PlainTimeBuilder()
  • Method Details

    • of

      public F_PlainTime of(String time)
      A time of day parsed from a string. Accepts 24-hour ("14:30", "14:30:00") and 12-hour with a meridiem suffix ("2:30pm"), and tolerates a single-digit hour.
      Parameters:
      time - the value to parse
      Returns:
      a time to continue the chain from

      Groovy example:
      f().time.of("2:30pm").toIso()

      Returns:
      "14:30"

      SpEL example:
      #f().time.of("2:30pm").toIso()
    • of

      public F_PlainTime of(LocalTime time)
      A time of day from a LocalTime.
      Parameters:
      time - the value to wrap
      Returns:
      a time to continue the chain from
    • of

      public F_PlainTime of(Map<String,Object> obj)
      A time of day from a map of hour and minute, each an integer or a numeric string.

      An amPm of "pm" shifts an hour below 12 into the afternoon, matching the front end. Omit it, or pass "am" or "mil", to read hour as a 24-hour value.

      Parameters:
      obj - map carrying hour and minute, and optionally amPm
      Returns:
      a time to continue the chain from

      Groovy example:
      f().time.of(['hour': 14, 'minute': 30]).toIso()

      Returns:
      "14:30"
    • of

      public F_PlainTime of(String hour, String minute)
      A time of day from a 24-hour hour and a minute, both as strings - the overload for values arriving from form fields or an import row. Matches the front end's of(hour, minute), so the same expression reads the same on both sides.
      Parameters:
      hour - the hour, 0-23
      minute - the minute, 0-59
      Returns:
      a time to continue the chain from
      Throws:
      DateTimeException - if the values are not a valid time

      Groovy example:
      f().time.of("14", "30").toIso()

      Returns:
      "14:30"

      SpEL example:
      #f().time.of("14", "30").toIso()
    • of

      public F_PlainTime of(String hour, String minute, String amPm)
      A time of day from an hour, a minute and a meridiem, all as strings - the front end's primary numeric form, so f().time.of("2", "30", "pm") reads the same on both sides.
      Parameters:
      hour - the hour; 1-12 with "am" / "pm", or 0-23 with "mil"
      minute - the minute, 0-59
      amPm - "am", "pm" or "mil"
      Returns:
      a time to continue the chain from
      Throws:
      IllegalArgumentException - if the hour, minute or meridiem is out of range

      Groovy example:
      f().time.of("2", "30", "pm").toIso()

      Returns:
      "14:30"

      SpEL example:
      #f().time.of("2", "30", "pm").toIso()
    • of

      public F_PlainTime of(int hour, int minute)
      A time of day from a 24-hour hour and a minute.
      Parameters:
      hour - the hour, 0-23
      minute - the minute, 0-59
      Returns:
      a time to continue the chain from

      Groovy example:
      f().time.of(14, 30).toIso()

      Returns:
      "14:30"

      SpEL example:
      #f().time.of(14, 30).toIso()
    • of

      public F_PlainTime of(int hour, int minute, String amPm)
      A time of day from an hour, a minute and a meridiem.
      Parameters:
      hour - the hour; 1-12 with "am" / "pm", or 0-23 with "mil"
      minute - the minute, 0-59
      amPm - "am", "pm" or "mil"
      Returns:
      a time to continue the chain from
      Throws:
      IllegalArgumentException - if the hour, minute or meridiem is out of range

      Groovy example:
      f().time.of(2, 30, "pm").toIso()

      Returns:
      "14:30"

      SpEL example:
      #f().time.of(2, 30, "pm").toIso()
    • now

      public F_PlainTime now()
      The current time of day, to the minute. Seconds are dropped, matching the front end's now() - a plain time carries no finer precision there.
      Returns:
      the current hour and minute, as a time to continue the chain from

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

      Returns:
      "17:24"

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