Created
March 13, 2018 05:32
-
-
Save peanutpi/37303354534a4e39f79ae5cdabde23a0 to your computer and use it in GitHub Desktop.
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
package com.peanutlabs.cron; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
import org.springframework.scheduling.support.CronSequenceGenerator; | |
public class SpringCronTester { | |
public static void main(String[] args) { | |
CronSequenceGenerator cron1 = new CronSequenceGenerator("0 0 */1 * * ?"); | |
Calendar cal = Calendar.getInstance(); | |
cal.add(Calendar.DATE, 2); // add two days to current date | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMM dd HH:mm:ss"); | |
System.out.println("current date " + sdf.format(cal.getTime())); | |
System.out.println("Next cron trigger date cron1 \n"); | |
Date date = cal.getTime(); | |
for (int i = 0; i < 10; i++) { | |
date = cron1.next(date); | |
System.out.println(date); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment