Difference between * and ? in Spring @Scheduled(cron=“…”)

I’ve been looking at the Spring Boot example for scheduling tasks (https://spring.io/guides/gs/scheduling-tasks/) and reading through some documentation (https://javahunter.wordpress.com/2011/05/05/cronscheduler-in-spring/) and I see that * and ? are used almost interchangeably.

For example, the line

@Scheduled(cron = "0 15 10 ? * *")


@Scheduled(cron = "0 15 10 * * ?")

do the exact same thing. So what is the difference between * and ?


asterix stands for all possible values. question marks should be used for non specific value

*(“all values”) – used to select all values within a field. For example, “” in the minute field means *”every minute”.

? (“no specific value”) – useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don’t care what day of the week that happens to be, I would put “10” in the day-of-month field, and “?” in the day-of-week field. See the examples below for clarification.

Copied from the tutorial

Source: stackoverflow