일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- vscode
- Mac
- context
- grep
- VirtualBox
- Source
- ssh
- Quartz
- find
- import
- Eclipse
- web.xml
- port
- tomcat
- 네트워크
- Windows 10
- JavaScript
- 줄바꿈 문자
- xargs
- bash
- resource
- GIT
- 단축키
- lsof
- maVen
- plugin
- IntelliJ
- profile
- Windows
- netsh
- Today
- Total
develog
Quartz cron expression test 본문
http://www.devexp.eu/2009/08/18/quartz-test-a-cron-expression/
public static void testCronExpression(String expression) {
System.out.println(">> testCronExpression() : " + expression);
try {
CronExpression cronExpression = new CronExpression(expression);
Date nextValidDate = new Date();
for (int i = 0; i < 10; i++) {
nextValidDate = cronExpression.getNextValidTimeAfter(nextValidDate);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(" " + formatter.format(nextValidDate));
}
} catch (ParseException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
testCronExpression("* * * * * ?");
testCronExpression("0/5 * * * * ?");
testCronExpression("0 0 0 * * ?");
}
// console output
>> testCronExpression() : * * * * * ?
2012-12-04 13:47:29
2012-12-04 13:47:30
2012-12-04 13:47:31
2012-12-04 13:47:32
2012-12-04 13:47:33
2012-12-04 13:47:34
2012-12-04 13:47:35
2012-12-04 13:47:36
2012-12-04 13:47:37
2012-12-04 13:47:38
>> testCronExpression() : 0/5 * * * * ?
2012-12-04 13:47:30
2012-12-04 13:47:35
2012-12-04 13:47:40
2012-12-04 13:47:45
2012-12-04 13:47:50
2012-12-04 13:47:55
2012-12-04 13:48:00
2012-12-04 13:48:05
2012-12-04 13:48:10
2012-12-04 13:48:15
>> testCronExpression() : 0 0 0 * * ?
2012-12-05 00:00:00
2012-12-06 00:00:00
2012-12-07 00:00:00
2012-12-08 00:00:00
2012-12-09 00:00:00
2012-12-10 00:00:00
2012-12-11 00:00:00
2012-12-12 00:00:00
2012-12-13 00:00:00
2012-12-14 00:00:00
'Dev > Java' 카테고리의 다른 글
java get ip (0) | 2012.12.14 |
---|---|
Apache Derby Eclipse plug-in (0) | 2012.12.08 |
Quartz Test (0) | 2012.12.04 |
ApplicationContext 가져오는 방법 (0) | 2012.12.04 |
DTD-style vs Xml Schem-style in Spring 2.5 (0) | 2012.12.04 |