The ScheduledExecutorService in Java is pretty handy for repeating tasks with either fixed intervals or fixed delay. I was wondering if there is an something like the existing ScheduledExecutorService that lets you specify a time of day to schedule the task at, rather than an interval i.e. ‘I want this task to fire at 10am each day’.
I know you can achieve this with Quartz, but I’d rather not use that library if possible (it’s a great library but I’d rather not have the dependency for a few reasons).
You can use the Timer class. Specifically, scheduleAtFixedRate(TimerTask task, Date firstTime, long period). Where you can set a task to start at 10am on a particular day and repeat every 24 hours.