Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- IntelliJ
- bash
- xargs
- port
- netsh
- import
- profile
- Quartz
- Windows
- vscode
- lsof
- Mac
- plugin
- web.xml
- GIT
- resource
- find
- tomcat
- grep
- 단축키
- context
- Source
- maVen
- ssh
- Eclipse
- Windows 10
- 네트워크
- JavaScript
- VirtualBox
- 줄바꿈 문자
Archives
- Today
- Total
develog
[Spring] spring cron expression test 본문
spring cron expression test
import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import org.springframework.scheduling.support.CronSequenceGenerator; public class TestCronExpression { public static void main(String[] args) { Calendar today = Calendar.getInstance(); today.set(2019, 2-1, 21); testCronExpression(today, "0 30 12 27-31,1-2 * ?"); } public static void testCronExpression(Calendar today, String expression) { System.out.println(">> testCronExpression() : " + expression); try { CronSequenceGenerator cronTrigger = new CronSequenceGenerator(expression); for (int i = 0; i < 62; i++) { Date nextExcecutionDate = cronTrigger.next(today.getTime()); System.out.println(formatDate(today.getTime()) + " => " + formatDate(nextExcecutionDate)); today.set(Calendar.DATE, today.get(Calendar.DATE) + 1); } } catch (Exception e) { System.err.println(e.getMessage()); } } public static String formatDate(Date date) { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); } } |
'Dev > Spring' 카테고리의 다른 글
[Spring] beans.xml 설정3, component-scan (0) | 2015.08.28 |
---|---|
[Spring] beans.xml 설정2, annotation-config (0) | 2015.08.28 |
[Spring] beans.xml 설정1, 기본 (0) | 2015.08.28 |
[Spring] beans.xml (0) | 2015.06.04 |
[Spring] Spring3 AOP 설정, xml or java (0) | 2015.06.04 |
Comments