package com.dmo.parkingview.util;
import lombok.extern.slf4j.Slf4j;
import org.quartz.impl.triggers.CronTriggerImpl;
import java.util.Date;
@Slf4j
public class CronUtil {
public static boolean isValidExpression(final String cronExpression) {
CronTriggerImpl trigger = new CronTriggerImpl();
try {
trigger.setCronExpression(cronExpression);
Date date = trigger.computeFirstFireTime(null);
return date != null && date.after(new Date());
} catch (Exception e) {
log.error("invalid expression:{},error msg:{}", cronExpression, e.getMessage());
}
return false;
}
}