I want to restrict a method to only be executable on weekdays. Is there a spring annotation that would allow for this? Im trying to avoid writing a method that just checks the day of the week and exits.
CodePudding user response:
I don't think there's any comment to check the day of the week in the spring.
You may need to use the following methods:
public void checkDate() {
LocalDate localDate = LocalDate.now();
DayOfWeek dayOfWeek = localDate.getDayOfWeek();
if(dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY) {
// ...do something
}
}