@@ -0,0 +1,2099 @@
+package com.cronutils;%0A%0Aimport java.time.ZoneId;%0Aimport java.time.ZonedDateTime;%0Aimport java.util.Optional;%0A%0Aimport org.junit.Test;%0A%0Aimport com.cronutils.model.Cron;%0Aimport com.cronutils.model.CronType;%0Aimport com.cronutils.model.definition.CronDefinition;%0Aimport com.cronutils.model.definition.CronDefinitionBuilder;%0Aimport com.cronutils.model.time.ExecutionTime;%0Aimport com.cronutils.parser.CronParser;%0A%0Apublic class Issue470Test %7B%0A%0A%09@Test%0A%09public void testWithoutYearInPattern() %7B%0A%09%09ZonedDateTime dt = ZonedDateTime.of(2021, 3, 23, 0, 0, 0, 0, ZoneId.of(%22UTC%22));%0A%09%09CronDefinition cd = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ);%0A%09%09CronParser parser = new CronParser(cd);%0A%09%09Cron cron = parser.parse(%220 0 0 23 3 ? *%22);%0A%09%09cron.validate();%0A%09%09System.out.println(cron.asString());%0A%09    ExecutionTime et1 = ExecutionTime.forCron(cron);%0A%09    Optional%3CZonedDateTime%3E next = et1.nextExecution(dt);%0A%09    Optional%3CZonedDateTime%3E last = et1.lastExecution(dt);%0A%09    System.out.println(%22Next: %22 + next + %22 Last: %22 + last);%0A%09    assert(!next.isEmpty());%09// Without year in pattern, there is always a next execution date%0A%09    assert(!last.isEmpty());%09// Without year in pattern, there is always a previous execution date%0A%09    assert(et1.isMatch(dt));%09// And, we also match this year%0A%09%7D%0A%0A%09@Test%0A%09public void testWithYearInPattern() %7B%0A%09%09ZonedDateTime dt = ZonedDateTime.of(2021, 3, 23, 0, 0, 0, 0, ZoneId.of(%22UTC%22));%0A%09%09CronDefinition cd = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ);%0A%09%09CronParser parser = new CronParser(cd);%0A%09%09Cron cron = parser.parse(%220 0 0 23 3 ? 2021%22);%0A%09%09cron.validate();%0A%09%09System.out.println(cron.asString());%0A%09    ExecutionTime et1 = ExecutionTime.forCron(cron);%0A%09    Optional%3CZonedDateTime%3E next = et1.nextExecution(dt);%0A%09    Optional%3CZonedDateTime%3E last = et1.lastExecution(dt);%0A%09    System.out.println(%22Next: %22 + next + %22 Last: %22 + last);%0A%09    assert(next.isEmpty());%09// We only should match once, on this exact date%0A%09    assert(last.isEmpty());%09// therefore, next and last should be (and are) empty%0A%09    assert(et1.isMatch(dt));// Fails in 9.1.3%0A%09%7D%0A%0A%7D%0A

Create Issue470Test.java