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.
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
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.