com.github.kagkarlsson.shaded.cronutils.utils.CronFrequencyComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of db-scheduler Show documentation
Show all versions of db-scheduler Show documentation
Simple persistent scheduler for scheduled tasks, recurring or ad-hoc.
package com.github.kagkarlsson.shaded.cronutils.utils;
import com.github.kagkarlsson.shaded.cronutils.model.Cron;
import com.github.kagkarlsson.shaded.cronutils.model.time.ExecutionTime;
import java.time.ZonedDateTime;
import java.util.Comparator;
public class CronFrequencyComparator implements Comparator {
private final ZonedDateTime startDate;
private final ZonedDateTime endDate;
public CronFrequencyComparator(ZonedDateTime startDate, ZonedDateTime endDate){
this.startDate = startDate;
this.endDate = endDate;
}
@Override
public int compare(Cron o1, Cron o2) {
int executions1 = ExecutionTime.forCron(o1).countExecutions(startDate, endDate);
int executions2 = ExecutionTime.forCron(o2).countExecutions(startDate, endDate);
return executions1-executions2;
}
}