Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CronExpression#getNextInvalidTimeAfter has a timezone bug #1076

Open
MIMehmet opened this issue Oct 26, 2023 · 0 comments
Open

CronExpression#getNextInvalidTimeAfter has a timezone bug #1076

MIMehmet opened this issue Oct 26, 2023 · 0 comments

Comments

@MIMehmet
Copy link

When calling this method across a timezone change, it returns a valid time instead of the next invalid time. This occurs when the input date is before a clock change, and the next invalid time is after a clock change.

For example, given a CronExpression with a timezone ID of "Europe/London", and the expression "* * * ? * 1", calling nextInvalidTimeAfter with a date of 2023-10-29T00:00:00+01:00 returns a date of 2023-10-29T01:00:00.000+0100. Expected value should be 2023-10-30T00:00Z.

Here's an example in code:

CronExpression cronExpression = new CronExpression("* * * ? * 1");
cronExpression.setTimeZone(TimeZone.getTimeZone(ZoneId.of("Europe/London")));
Date date = Date.from(Instant.parse("2023-10-29T00:00:00+01:00"));

Date nextInvalidTime = cronExpression.getNextInvalidTimeAfter(date);

assertFalse(cronExpression.isSatisfiedBy(nextInvalidTime)); // fails
assertEquals(nextInvalidTime, Date.from(Instant.parse("2023-10-30T00:00:00Z"))); // fails; actual: 2023-10-29T01:00:00+01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant