Class Durations

java.lang.Object
org.forgerock.util.time.Durations

public final class Durations extends Object
Helper class for working with Duration objects.
  • Field Details

    • UNLIMITED

      public static final Duration UNLIMITED
      Representation of an unlimited duration.
  • Method Details

    • isUnlimited

      public static boolean isUnlimited(Duration duration)
      Whether a given duration is considered unlimited.
      Parameters:
      duration - The duration to evaluate.
      Returns:
      Whether the duration is unlimited.
    • isPositive

      public static boolean isPositive(Duration duration)
      Whether a given duration is positive.
      Parameters:
      duration - The duration to evaluate.
      Returns:
      Whether the duration is positive.
    • duration

      public static Duration duration(long number, TimeUnit unit)
      Creates a Duration, given a number and time unit.
      Parameters:
      number - number of time unit.
      unit - TimeUnit to express the duration in (cannot be null).
      Returns:
      Duration instance
    • duration

      public static Duration duration(String value)
      Parses a Duration from a human-readable string.
      Parameters:
      value - The human-readable duration string to parse.
      Returns:
      The parsed duration.
    • toString

      public static String toString(Duration duration)
      Creates a readable representation of a Duration. The method will choose the largest unit that can accurately represent the duration.
      Parameters:
      duration - The duration to convert.
      Returns:
      The string representation of the duration, in seconds.