[
https://issues.apache.org/jira/browse/AMQ-6217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15214476#comment-15214476
]
Timothy Bish commented on AMQ-6217:
-----------------------------------
Many cron tools prohibit the combined use of the days of week field and the
days of month field in a cron expression restricting the one or the other to
'?' when either is used. I supposed if we are to put any fix in for this I go
with something along those lines also given the generally complexity of
supporting the combined use of both values.
> CronParser.getNextScheduledTime() with dayOfMonth and dayOfWeek
> ---------------------------------------------------------------
>
> Key: AMQ-6217
> URL: https://issues.apache.org/jira/browse/AMQ-6217
> Project: ActiveMQ
> Issue Type: Bug
> Components: Broker
> Affects Versions: 5.12.2, 5.13.2
> Environment: Windows Java 1.8
> Reporter: Rafael Fuentes
>
> When we try to get several “NextSecheduledTime” for a cron string that have
> set the “day of month” and the “day of week “at the same time, CronParser
> returns “days of month” that do not match with the defined “days of week”.
> For example:
> public static void main(String[] args){
> try
> {
> DateFormat format = new SimpleDateFormat("yyyy/MM/dd");
> Date executionDate = format.parse("2016/09/11");
> Date end = format.parse("2016/10/31");
> String cron ="45 6 1,2,3,4,5,6,7,8,9,10,11 * 1,2,3,4,5";
> executionDate = new Date(CronParser.getNextScheduledTime(cron,
> executionDate.getTime()));
>
> while (executionDate.compareTo(end) < 0) {
>
> System.out.println(executionDate);
> executionDate = new Date(CronParser.getNextScheduledTime(cron,
> executionDate.getTime()));
> }
> }
> catch(Exception e)
> { e.printStackTrace(); }
> }
> This outputs:
> Sun Oct 02 06:45:00 CEST 2016
> Mon Oct 03 06:45:00 CEST 2016
> Tue Oct 04 06:45:00 CEST 2016
> Wed Oct 05 06:45:00 CEST 2016
> Thu Oct 06 06:45:00 CEST 2016
> Fri Oct 07 06:45:00 CEST 2016
> Mon Oct 10 06:45:00 CEST 2016
> Tue Oct 11 06:45:00 CEST 2016
> Cron string defines “Monday to Friday” but CronParser returns “Sunday”.
> I think it shouldn’t return Sunday, it should start on Mon Oct 03.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)