java - Scheduler for a task to run at particular hour of the day for every N days -


i looking scheduler should run @ particular hour in day every n specified days.

for example, task should run @ 11pm every 10 days.

the hour can configured using cron expression, how set interval.

thanks help

you can use java.util.concurrent.scheduledexecutorservice

private final scheduledexecutorservice scheduler = executors.newscheduledthreadpool(1); scheduler.scheduleatfixedrate(command, gettonight10pm(), period, unit); 

update: set initialdelay, can set time in gregoriancalendar 10 pm , pass argument

private static date gettonight10pm() {         calendar today = new gregoriancalendar();         calendar result =             new gregoriancalendar(today.get(calendar.year), today.get(calendar.month), today.get(calendar.date), 23, 0);         return result.gettime(); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -