Jak uruchamiać określone zadanie każdego dnia o określonej godzinie przy użyciu usługi ScheduledExecutorService?

Próbuję wykonać pewne zadanie codziennie o 5 rano. Więc postanowiłem użyćScheduledExecutorService ale do tej pory widziałem przykłady pokazujące, jak uruchamiać zadanie co kilka minut.

I nie jestem w stanie znaleźć żadnego przykładu, który pokazuje, w jaki sposób uruchamiać zadanie codziennie o określonej godzinie (5 rano) rano, a także biorąc pod uwagę fakt czasu letniego -

Poniżej znajduje się mój kod, który będzie uruchamiany co 15 minut -

public class ScheduledTaskExample {
    private final ScheduledExecutorService scheduler = Executors
        .newScheduledThreadPool(1);

    public void startScheduleTask() {
    /**
    * not using the taskHandle returned here, but it can be used to cancel
    * the task, or check if it's done (for recurring tasks, that's not
    * going to be very useful)
    */
    final ScheduledFuture<?> taskHandle = scheduler.scheduleAtFixedRate(
        new Runnable() {
            public void run() {
                try {
                    getDataFromDatabase();
                }catch(Exception ex) {
                    ex.printStackTrace(); //or loggger would be better
                }
            }
        }, 0, 15, TimeUnit.MINUTES);
    }

    private void getDataFromDatabase() {
        System.out.println("getting data...");
    }

    public static void main(String[] args) {
        ScheduledTaskExample ste = new ScheduledTaskExample();
        ste.startScheduleTask();
    }
}

Czy jest jakiś sposób, mogę zaplanować zadanie, które będzie uruchamiane codziennie 5 rano ranoScheduledExecutorService biorąc pod uwagę także czas letni?

I równieżTimerTask jest lepszy dla tego lubScheduledExecutorService?

questionAnswers(10)

yourAnswerToTheQuestion