public boolean isMatch ( ZonedDateTime date ) { // Issue #200: Truncating the date to the least granular precision supported by different cron systems. // For Quartz, it's seconds while for Unix & Cron4J it's minutes. final boolean isSecondGranularity = cronDefinition . containsFieldDefinition ( SECOND ) ; if ( isSecondGranularity ) { date = date . truncatedTo ( SECONDS ) ; } else { date = date . truncatedTo ( ChronoUnit . MINUTES ) ; } final Optional < ZonedDateTime > last = lastExecution ( date ) ; if ( last . isPresent ( ) ) { final Optional < ZonedDateTime > next = nextExecution ( last . get ( ) ) ; if ( next . isPresent ( ) ) { return next . get ( ) . equals ( date ) ; } else { boolean everythingInRange = false ; try { everythingInRange = dateValuesInExpectedRanges ( nextClosestMatch ( date ) , date ) ; } catch ( final NoSuchValueException ignored ) { // Why is this ignored? } try { everythingInRange = dateValuesInExpectedRanges ( previousClosestMatch ( date ) , date ) ; } catch ( final NoSuchValueException ignored ) { // Why is this ignored? } return everythingInRange ; } } return false ; }
Provide feedback if a given date matches the cron expression .