Package jenkins.util
Class TimeDuration
- java.lang.Object
-
- jenkins.util.TimeDuration
-
public class TimeDuration extends Object
Represents a length of something, like3sec
. This supports parameter injection, such as viaQueryParameter
.- Since:
- 1.489
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TimeDuration.StaplerConverterImpl
-
Constructor Summary
Constructors Constructor Description TimeDuration(long millis)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description long
as(TimeUnit t)
static TimeDuration
fromString(String delay)
Creates aTimeDuration
from the delay passed in parameterint
getTime()
Deprecated.usegetTimeInMillis()
instead.long
getTimeInMillis()
Returns the duration of this instance in milliseconds.int
getTimeInSeconds()
Returns the duration of this instance in seconds.
-
-
-
Method Detail
-
getTime
@Deprecated public int getTime()
Deprecated.usegetTimeInMillis()
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 aTimeDuration
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.
-
-