@Test public void testSleep() { assertTrue(Duration.seconds(0.5).lessThan(Duration.benchmark(new Runnable() { @Override public void run() { Duration.seconds(1.5).sleep(); } }))); assertTrue(Duration.seconds(1).greaterThan(Duration.benchmark(new Runnable() { @Override public void run() { Duration.hours(-1).sleep(); } }))); }
public final void sleep() { if (getMilliseconds() > 0) { try { Thread.sleep(getMilliseconds()); } catch (InterruptedException e) { } } }
Duration extends AbstractTimeValue { public final void sleep() { if (getMilliseconds() > 0) { try { Thread.sleep(getMilliseconds()); } catch (InterruptedException e) { } } } }
Duration extends AbstractTimeValue { public final void sleep() { if (getMilliseconds() > 0) { try { Thread.sleep(getMilliseconds()); } catch (InterruptedException e) { } } } protected  Duration(final long milliseconds); }
Duration extends AbstractTimeValue { public final void sleep() { if (getMilliseconds() > 0) { try { Thread.sleep(getMilliseconds()); } catch (InterruptedException e) { } } } protected  Duration(final long milliseconds); static Duration benchmark(final Runnable code); static Duration days(final double days); static Duration days(final int days); static Duration elapsed(final Time start); static Duration hours(final double hours); static Duration hours(final int hours); static Duration milliseconds(final double milliseconds); static Duration milliseconds(final long milliseconds); static Duration minutes(final double minutes); static Duration minutes(final int minutes); static Duration seconds(final double seconds); static Duration seconds(final int seconds); static Duration valueOf(final long time); static Duration valueOf(final String string); static Duration valueOf(final String string, final Locale locale); Duration add(final Duration duration); final double days(); final double hours(); final double minutes(); final double seconds(); final void sleep(); Duration subtract(final Duration that); String toString(); String toString(final Locale locale); }
Duration extends AbstractTimeValue { public final void sleep() { if (getMilliseconds() > 0) { try { Thread.sleep(getMilliseconds()); } catch (InterruptedException e) { } } } protected  Duration(final long milliseconds); static Duration benchmark(final Runnable code); static Duration days(final double days); static Duration days(final int days); static Duration elapsed(final Time start); static Duration hours(final double hours); static Duration hours(final int hours); static Duration milliseconds(final double milliseconds); static Duration milliseconds(final long milliseconds); static Duration minutes(final double minutes); static Duration minutes(final int minutes); static Duration seconds(final double seconds); static Duration seconds(final int seconds); static Duration valueOf(final long time); static Duration valueOf(final String string); static Duration valueOf(final String string, final Locale locale); Duration add(final Duration duration); final double days(); final double hours(); final double minutes(); final double seconds(); final void sleep(); Duration subtract(final Duration that); String toString(); String toString(final Locale locale); static final Duration MAXIMUM; static final Duration NONE; static final Duration ONE_DAY; static final Duration ONE_HOUR; static final Duration ONE_MINUTE; static final Duration ONE_SECOND; static final Duration ONE_WEEK; }