Skip to content

Commit

Permalink
cron expression based on hutool-cron
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyachao committed Mar 13, 2020
1 parent c5edc28 commit a3517a5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pattern-tutor/pattern-tutor-syntax/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,16 @@
<artifactId>dnsjava</artifactId>
<version>2.1.8</version>
</dependency> -->

<!-- <dependency>
<groupId>com.cronutils</groupId>
<artifactId>cron-utils</artifactId>
<version>9.0.2</version>
</dependency> -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-cron</artifactId>
<version>5.2.2</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.pattern.tutor.syntax.timer;

import java.util.Date;

import cn.hutool.cron.CronUtil;

/**
* <p>
* 通过指定cron方式执行任务<br/>
* 资料链接<a href="https://www.bookstack.cn/read/hutool/0f082d6e35363da6.md">https://www.bookstack.cn/read/hutool/0f082d6e35363da6.md</a>
* </p>
*
* @author buildupchao
* @date 2020/3/13
*/
public class CrontabExample {

public static void main(String[] args) throws InterruptedException {
CronUtil.schedule("18 17 * * *", new Runnable() {

@Override
public void run() {
System.out.println("test cron task, it's real! time is " + new Date());
}
});
CronUtil.start();
while (true) {
Thread.sleep(1000);
System.out.println("wait print..." + new Date());
}
}

}

0 comments on commit a3517a5

Please sign in to comment.