Meet Janitor, a timer that runs everyday at 3am.
Timer janitorTimer = new Timer();
TimerTask janitorWorker = new Janitor(); // Extending TimerTask
long delay = TimeUtils.getMillisUntilTomorrowAt( 3L * 3600000L); // Does what it says
janitorTimer.scheduleAtFixedRate( janitorWorker, delay, 24L * 3600000L);
At certain point in time I would like to know when is next janitorWorker execution.
Couldn’t find anything relevant in Timer nor TimerTask.
Feels that something either should already know.
In your implementation of
TimerTaskyou could expose the thenextExecutionTime, and then comapre that to the current time, see themainLoopinTimer