os.failsafe.executor.schedule.DailySchedule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of failsafe-executor Show documentation
Show all versions of failsafe-executor Show documentation
Persistent executor service for Java
package os.failsafe.executor.schedule;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Optional;
public class DailySchedule implements Schedule {
private final LocalTime dailyTime;
public DailySchedule(LocalTime dailyTime) {
this.dailyTime = dailyTime;
}
@Override
public Optional nextExecutionTime(LocalDateTime currentTime) {
LocalDate nextExecutionDate;
if(dailyTime.isAfter(currentTime.toLocalTime())) {
nextExecutionDate = currentTime.toLocalDate();
} else {
nextExecutionDate = currentTime.toLocalDate().plusDays(1);
}
return Optional.of(LocalDateTime.of(nextExecutionDate, dailyTime));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy