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

The tutorial is outdated. The symbol ? means exactly the same as the symbol *.

As of Spring version 3.1.2.RELEASE, the call hierarchy is the following:

  1. The constructor CronTrigger(String) calls the constructor CronSequenceGenerator(String)
  2. CronSequenceGenerator(String) calls parse(String)
  3. parse(String) calls setDays(BitSet bits, String field, int max).

Its implementation is clear:

private void setDays(BitSet bits, String field, int max) {
    if (field.contains("?")) {
        field = "*";
    }
    setNumberHits(bits, field, 0, max);
}

So, if ?, then *.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)