-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cron expression based on hutool-cron
- Loading branch information
zhangyachao
committed
Mar 13, 2020
1 parent
c5edc28
commit a3517a5
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...tor/pattern-tutor-syntax/src/main/java/com/pattern/tutor/syntax/timer/CrontabExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
|
||
} |