fixed cron example (SPR-6772)
This commit is contained in:
parent
6070a498fe
commit
9c44f9252d
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2010 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -28,20 +28,19 @@ import java.util.TimeZone;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date sequence generator for a <a
|
* Date sequence generator for a <a href="http://www.manpagez.com/man/5/crontab/">Crontab pattern</a>,
|
||||||
* href="http://www.manpagez.com/man/5/crontab/">Crontab pattern</a> allowing
|
* allowing clients to specify a pattern that the sequence matches.
|
||||||
* client to specify a pattern that the sequence matches. The pattern is a list
|
|
||||||
* of 6 single space separated fields representing (second, minute, hour, day,
|
|
||||||
* month, weekday). Month and weekday names can be given as the first three
|
|
||||||
* letters of the English names.<br/>
|
|
||||||
* <br/>
|
|
||||||
*
|
*
|
||||||
* Example patterns
|
* <p>The pattern is a list of six single space-separated fields: representing
|
||||||
|
* second, minute, hour, day, month, weekday. Month and weekday names can be
|
||||||
|
* given as the first three letters of the English names.
|
||||||
|
*
|
||||||
|
* <p>Example patterns:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>"0 0 * * * *" = the top of every hour of every day.</li>
|
* <li>"0 0 * * * *" = the top of every hour of every day.</li>
|
||||||
* <li>"*/10 * * * * *" = every ten seconds.</li>
|
* <li>"*/10 * * * * *" = every ten seconds.</li>
|
||||||
* <li>"0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.</li>
|
* <li>"0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.</li>
|
||||||
* <li>"0 0 8-10/30 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.</li>
|
* <li>"0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.</li>
|
||||||
* <li>"0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays</li>
|
* <li>"0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays</li>
|
||||||
* <li>"0 0 0 25 12 ?" = every Christmas Day at midnight</li>
|
* <li>"0 0 0 25 12 ?" = every Christmas Day at midnight</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
|
@ -69,6 +68,7 @@ class CronSequenceGenerator {
|
||||||
|
|
||||||
private final TimeZone timeZone;
|
private final TimeZone timeZone;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a {@link CronSequenceGenerator} from the pattern provided.
|
* Construct a {@link CronSequenceGenerator} from the pattern provided.
|
||||||
* @param expression a space-separated list of time fields
|
* @param expression a space-separated list of time fields
|
||||||
|
|
@ -81,6 +81,7 @@ class CronSequenceGenerator {
|
||||||
parse(expression);
|
parse(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next {@link Date} in the sequence matching the Cron pattern and
|
* Get the next {@link Date} in the sequence matching the Cron pattern and
|
||||||
* after the value provided. The return value will have a whole number of
|
* after the value provided. The return value will have a whole number of
|
||||||
|
|
@ -127,7 +128,7 @@ class CronSequenceGenerator {
|
||||||
List<Integer> resets = new ArrayList<Integer>();
|
List<Integer> resets = new ArrayList<Integer>();
|
||||||
|
|
||||||
int second = calendar.get(Calendar.SECOND);
|
int second = calendar.get(Calendar.SECOND);
|
||||||
List<Integer> emptyList = Collections.<Integer> emptyList();
|
List<Integer> emptyList = Collections.emptyList();
|
||||||
int updateSecond = findNext(this.seconds, second, calendar, Calendar.SECOND, Calendar.MINUTE, emptyList);
|
int updateSecond = findNext(this.seconds, second, calendar, Calendar.SECOND, Calendar.MINUTE, emptyList);
|
||||||
if (second == updateSecond) {
|
if (second == updateSecond) {
|
||||||
resets.add(Calendar.SECOND);
|
resets.add(Calendar.SECOND);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue