// For 5.00 am time period.
int InHrs = 17;
int InMinutes = 00;
scheduler = Akka.system().scheduler().schedule(Duration.create(nextExecutionInSeconds(InHrs, InMinutes), TimeUnit.SECONDS),
Duration.create(24, TimeUnit.HOURS),
new Runnable() {
@Override
public void run() {
// Call your method
System.out.println("EVERY 24:00 Later --- " + System.currentTimeMillis());
}
},
Akka.system().dispatcher());
public static int nextExecutionInSeconds(int hour, int minute){
return Seconds.secondsBetween(
new DateTime(),
nextExecution(hour, minute)
).getSeconds();
}
public static DateTime nextExecution(int hour, int minute){
DateTime next = new DateTime()
.withHourOfDay(hour)
.withMinuteOfHour(minute)
.withSecondOfMinute(0)
.withMillisOfSecond(0);
return (next.isBeforeNow())
? next.plusHours(24)
: next;
}
Повторите это для 10-часового периода времени, который будет равен 22 inHrs. Надеюсь, это решает проблему.