Package jenkins.util

Class TimeDuration

java.lang.Object
jenkins.util.TimeDuration

public class TimeDuration extends Object
Represents a length of something, like 3sec. This supports parameter injection, such as via QueryParameter.
Since:
1.489
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • TimeDuration

      public TimeDuration(long millis)
  • Method Details

    • getTime

      @Deprecated public int getTime()
      Deprecated.
      use getTimeInMillis() instead. This method has always returned a time in milliseconds, when various callers incorrectly assumed seconds. And this spread through the codebase. So this has been deprecated for clarity in favour of more explicitly named methods.
      Returns the duration of this instance in milliseconds.
    • getTimeInMillis

      public long getTimeInMillis()
      Returns the duration of this instance in milliseconds.
    • getTimeInSeconds

      public int getTimeInSeconds()
      Returns the duration of this instance in seconds.
      Since:
      2.82
    • as

      public long as(TimeUnit t)
    • fromString

      @CheckForNull public static TimeDuration fromString(@CheckForNull String delay)
      Creates a TimeDuration from the delay passed in parameter
      Parameters:
      delay - the delay either in milliseconds without unit, or in seconds if suffixed by sec or secs.
      Returns:
      the TimeDuration created from the delay expressed as a String.