Class Time


public class Time extends AbstractProvider<BaseProviders>
Since:
1.4.0
  • Constructor Details

  • Method Details

    • future

      public long future(int atMost, ChronoUnit unit)
      Generates a future time from now. Note that there is a 1 second slack to avoid generating a past time.
      Parameters:
      atMost - at most this amount of time ahead from now exclusive.
      unit - the time unit.
      Returns:
      a future time from now.
    • future

      public String future(int atMost, ChronoUnit unit, String pattern)
      Generates and converts to string representation a future time from now. Note that there is a 1 second slack to avoid generating a past time.
      Parameters:
      atMost - at most this amount of time ahead from now exclusive.
      unit - the time unit.
      pattern - time pattern to convert to string.
      Returns:
      a string representation of a future time from now.
    • future

      public long future(int atMost, int minimum, ChronoUnit unit)
      Generates a future time from now, with a minimum time.
      Parameters:
      atMost - at most this amount of time ahead from now exclusive.
      minimum - the minimum amount of time in the future from now.
      unit - the time unit.
      Returns:
      a future time from now, with a minimum time.
    • future

      public String future(int atMost, int minimum, ChronoUnit unit, String pattern)
      Generates and converts to string representation of a future time from now, with a minimum time.
      Parameters:
      atMost - at most this amount of time ahead from now exclusive.
      minimum - the minimum amount of time in the future from now.
      unit - the time unit.
      pattern - time pattern to convert to string.
      Returns:
      a string representation of a future time from now, with a minimum time.
    • past

      public long past(int atLeast, ChronoUnit unit)
      Generates a past time from now. Note that there is a 1 second slack added.
      Parameters:
      atLeast - at most this amount of time earlier from now exclusive.
      unit - the time unit.
      Returns:
      a past time from now.
    • past

      public String past(int atMost, ChronoUnit unit, String pattern)
      Generates a string representation of a past time from now. Note that there is a 1 second slack added.
      Parameters:
      atMost - at most this amount of time earlier from now exclusive.
      unit - the time unit.
      pattern - time pattern to convert to string.
      Returns:
      a string representation of a past time from now.
    • past

      public long past(int atMost, int minimum, ChronoUnit unit)
      Generates a past time from now, with a minimum time.
      Parameters:
      atMost - at most this amount of time earlier from now exclusive.
      minimum - the minimum amount of time in the past from now.
      unit - the time unit.
      Returns:
      a past time from now.
    • past

      public String past(int atMost, int minimum, ChronoUnit unit, String pattern)
      Generates and converts to string representation a past time from now, with a minimum time.
      Parameters:
      atMost - at most this amount of time earlier from now exclusive.
      minimum - the minimum amount of time in the past from now.
      unit - the time unit.
      pattern - time pattern to convert to string.
      Returns:
      a string representation of a past time from now, with a minimum time.
    • between

      public long between(LocalTime from, LocalTime to) throws IllegalArgumentException
      Generates a random time between two times.
      Parameters:
      from - the lower bound inclusive
      to - the upper bound exclusive
      Returns:
      a random time between from and to.
      Throws:
      IllegalArgumentException - if the to time represents an earlier time than from time.
    • between

      public String between(LocalTime from, LocalTime to, String pattern) throws IllegalArgumentException
      Generates a string representation of a random time between two times.
      Parameters:
      from - the lower bound inclusive
      to - the upper bound exclusive
      pattern - time pattern to convert to string.
      Returns:
      a string representation of a random time between from and to.
      Throws:
      IllegalArgumentException - if the to time represents an earlier time than from time.