diff --git a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java index 87fb6df4d1d8..b883d3e77bbf 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java +++ b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java @@ -20,6 +20,7 @@ import static com.google.common.util.concurrent.Internal.toNanosSaturated; import static com.google.common.util.concurrent.MoreExecutors.directExecutor; import static java.util.Objects.requireNonNull; +import static java.util.concurrent.TimeUnit.NANOSECONDS; import com.google.common.annotations.GwtIncompatible; import com.google.common.base.Supplier; @@ -128,7 +129,7 @@ public abstract static class Scheduler { */ public static Scheduler newFixedDelaySchedule(Duration initialDelay, Duration delay) { return newFixedDelaySchedule( - toNanosSaturated(initialDelay), toNanosSaturated(delay), TimeUnit.NANOSECONDS); + toNanosSaturated(initialDelay), toNanosSaturated(delay), NANOSECONDS); } /** @@ -165,7 +166,7 @@ public Cancellable schedule( */ public static Scheduler newFixedRateSchedule(Duration initialDelay, Duration period) { return newFixedRateSchedule( - toNanosSaturated(initialDelay), toNanosSaturated(period), TimeUnit.NANOSECONDS); + toNanosSaturated(initialDelay), toNanosSaturated(period), NANOSECONDS); } /** @@ -722,6 +723,14 @@ public Schedule(long delay, TimeUnit unit) { this.delay = delay; this.unit = checkNotNull(unit); } + + /** + * @param delay the time from now to delay execution + * @since NEXT + */ + public Schedule(Duration delay) { + this(toNanosSaturated(delay), NANOSECONDS); + } } /**