You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/12/20 19:49:00 UTC
[jira] [Commented] (AMQ-6327) getNextScheduledTime() returns
incorrect time when working with day of month
[ https://issues.apache.org/jira/browse/AMQ-6327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16298984#comment-16298984 ]
ASF GitHub Bot commented on AMQ-6327:
-------------------------------------
GitHub user snurmine opened a pull request:
https://github.com/apache/activemq/pull/267
AMQ-6327 - getNextScheduledTime() returns incorrect time when working…
… with day of month
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/snurmine/activemq AMQ-6327
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/activemq/pull/267.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #267
----
----
> getNextScheduledTime() returns incorrect time when working with day of month
> ----------------------------------------------------------------------------
>
> Key: AMQ-6327
> URL: https://issues.apache.org/jira/browse/AMQ-6327
> Project: ActiveMQ
> Issue Type: Bug
> Components: Broker
> Affects Versions: 5.12.0, 5.13.3
> Reporter: Justin Novak
> Priority: Minor
>
> Given the following code
> {code:java}
> DateFormat format = new SimpleDateFormat("yyyy/MM/dd");
> try {
> // cron, currentDate, expectedDate
> String[][] tests = new String[][]{
> { "0 0 1 * *", "2016/04/15", "2016/05/01" },
> { "0 0 1,15 * *", "2016/04/15", "2016/05/01" },
> { "0 0 1 * *", "2016/05/15", "2016/06/01" },
> { "0 0 1,15 * *", "2016/05/15", "2016/06/01" },
> { "0 0 1 * *", "2016/06/15", "2016/07/01" },
> { "0 0 1,15 * *", "2016/06/15", "2016/07/01" },
> };
> String cron;
> Date currentDate;
> Date expectedDate;
> Date nextDate;
> for (int i = 0; i < tests.length; i++) {
> cron = tests[i][0];
> currentDate = format.parse(tests[i][1]);
> expectedDate = format.parse(tests[i][2]);
> nextDate = new Date(CronParser.getNextScheduledTime(cron, currentDate.getTime()));
> System.out.println(String.format("CronParser.getNextScheduledTime('%s', '%s') == '%s' // Expected: '%s'", cron, currentDate, nextDate, expectedDate));
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> {code}
> The output is
> {code}
> CronParser.getNextScheduledTime('0 0 1 * *', 'Fri Apr 15 00:00:00 UTC 2016') == 'Wed Jun 01 00:00:00 UTC 2016' // Expected: 'Sun May 01 00:00:00 UTC 2016'
> CronParser.getNextScheduledTime('0 0 1,15 * *', 'Fri Apr 15 00:00:00 UTC 2016') == 'Sun May 15 00:00:00 UTC 2016' // Expected: 'Sun May 01 00:00:00 UTC 2016'
> CronParser.getNextScheduledTime('0 0 1 * *', 'Sun May 15 00:00:00 UTC 2016') == 'Wed Jun 01 00:00:00 UTC 2016' // Expected: 'Wed Jun 01 00:00:00 UTC 2016'
> CronParser.getNextScheduledTime('0 0 1,15 * *', 'Sun May 15 00:00:00 UTC 2016') == 'Wed Jun 01 00:00:00 UTC 2016' // Expected: 'Wed Jun 01 00:00:00 UTC 2016'
> CronParser.getNextScheduledTime('0 0 1 * *', 'Wed Jun 15 00:00:00 UTC 2016') == 'Mon Aug 01 00:00:00 UTC 2016' // Expected: 'Fri Jul 01 00:00:00 UTC 2016'
> CronParser.getNextScheduledTime('0 0 1,15 * *', 'Wed Jun 15 00:00:00 UTC 2016') == 'Fri Jul 15 00:00:00 UTC 2016' // Expected: 'Fri Jul 01 00:00:00 UTC 2016'
> {code}
> When given 1 for the day of month it's returning 1 month to many every other month
> When given 1,15 for the day of month it's returning the correct month but incorrect day of month every other month
> I've tested this on both v5.12.0 and v5.13.3
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)