It's my first time using the annotation @Scheduled
and i need it to repeat the code evry hour from 8to20 from monday to friday, so i used one of the multiple cron generator online and this is what came out :
@Scheduled(cron = "0 0 8-20 ? * MON-FRI *")
public void deleteExpiredSlots() {
//my code here
}
i get this error Cron expression must consist of 6 fields (found 7 in "0 0 8-20 ? * MON-FRI *")
I removed the ?
and the error changed to Encountered invalid @Scheduled method 'deleteExpiredSlots': For input string: "MON" 'MON-FRI' in cron expression "0 0 8-20 * MON-FRI *"
Someone knows what's the problem and possibly how to solve it?