markdown-it
demo
Delete
Submit
clear
permalink
```java @Configuration @EnableScheduling public class SpringConfig { // ... } ``` ```java /** * second minute hour dayOfMonth month dayOfWeek */ @Scheduled(cron = "0 15 10 15 * ?") public void scheduleTaskUsingCronExpression() { long now = System.currentTimeMillis() / 1000; System.out.println("schedule tasks using cron jobs - " + now); } private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); @Scheduled(cron = "0/5 * * * * *") public void scheduled(){ log.info("The time is now {}", dateFormat.format(new Date())); } @Scheduled(fixedRate = 5000) public void scheduled1() { log.info("=====>>>>>Use fixedRate: " + dateFormat.format(new Date())); } @Scheduled(fixedDelay = 5000) public void scheduled2() { log.info("=====>>>>>fixedDelay: " + dateFormat.format(new Date())); } ```
html
source
debug
Fork me on GitHub