public class TimeUtils
extends java.lang.Object
Constructor and Description |
---|
TimeUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
sleepFor(long period,
java.util.concurrent.TimeUnit timeUnit)
This method is a convenience method for sleep that "swallows"
InterruptedException and
has TimeUnit parameter in addition to time period so it makes it very convenient. |
static void |
sleepFor(TimeInterval timeInterval)
This is an overload for method
sleepFor(long, TimeUnit) which is provided for convenience. |
public static void sleepFor(long period, java.util.concurrent.TimeUnit timeUnit)
InterruptedException
and
has TimeUnit
parameter in addition to time period so it makes it very convenient. So with
this method there is no need to convert the time into milliseconds. Just simply write
sleepFor(10, TimeUnit.SECONDS);
period
- time period to sleeptimeUnit
- TimeUnit
that specifies in which units the time period is measuredpublic static void sleepFor(TimeInterval timeInterval)
sleepFor(long, TimeUnit)
which is provided for convenience.
Method sleepFor(long, TimeUnit)
could be very readable if you use actual values, for example
sleepFor(10, TimeUnit.SECONDS);
TimeInterval
, then
it doesn't make it any more readable to write
TimeUtils.sleepFor(timeInterval.getValue(), timeInterval.getTimeUnit());
timeInterval
- TimeInterval
instance that holds the time period to be waited for