From e04f56ce4f9945c303fd9057b60b4145b1a902b9 Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 23 Jul 2008 21:49:27 +0000 Subject: [PATCH] Patch from Charlie Groves: Convenience method to schedule a non-recurring Interval at a specific time. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2342 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/Interval.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/java/com/samskivert/util/Interval.java b/src/java/com/samskivert/util/Interval.java index 8062187f..fa656c8e 100644 --- a/src/java/com/samskivert/util/Interval.java +++ b/src/java/com/samskivert/util/Interval.java @@ -20,6 +20,7 @@ package com.samskivert.util; +import java.util.Date; import java.util.Timer; import java.util.TimerTask; @@ -77,6 +78,15 @@ public abstract class Interval */ public abstract void expired (); + /** + * Schedules this interval to execute once at when. Supersedes any previous + * schedule that this Interval may have had. + */ + public final void schedule (Date when) + { + schedule(when.getTime() - System.currentTimeMillis()); + } + /** * Schedule the interval to execute once, after the specified delay. Supersedes any previous * schedule that this Interval may have had.