本文整理汇总了Java中it.sauronsoftware.cron4j.SchedulingPattern.validate方法的典型用法代码示例。如果您正苦于以下问题:Java SchedulingPattern.validate方法的具体用法?Java SchedulingPattern.validate怎么用?Java SchedulingPattern.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.sauronsoftware.cron4j.SchedulingPattern
的用法示例。
在下文中一共展示了SchedulingPattern.validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeSave
import it.sauronsoftware.cron4j.SchedulingPattern; //导入方法依赖的package包/类
/**
* Before Save
* @param newRecord new
* @return true
*/
@Override
protected boolean beforeSave(boolean newRecord)
{
// Set Schedule Type & Frequencies
if (SCHEDULETYPE_Frequency.equals(getScheduleType()))
{
if (getFrequencyType() == null)
setFrequencyType(FREQUENCYTYPE_Day);
if (getFrequency() < 1)
setFrequency(1);
setCronPattern(null);
}
else if (SCHEDULETYPE_CronSchedulingPattern.equals(getScheduleType()))
{
String pattern = getCronPattern();
if (pattern != null && pattern.trim().length() > 0)
{
if (!SchedulingPattern.validate(pattern))
{
throw new AdempiereException("@[email protected]");
}
}
}
return true;
}
示例2: validateCronExp
import it.sauronsoftware.cron4j.SchedulingPattern; //导入方法依赖的package包/类
@RequestMapping(value = "exp.do",method= RequestMethod.POST)
@ResponseBody
public boolean validateCronExp(Integer cronType, String cronExp) {
boolean pass = false;
if (cronType == 0) pass = SchedulingPattern.validate(cronExp);
if (cronType == 1) pass = CronExpression.isValidExpression(cronExp);
return pass;
}
示例3: newScheduler
import it.sauronsoftware.cron4j.SchedulingPattern; //导入方法依赖的package包/类
@Override
public Scheduler newScheduler(Config config, ZoneId timeZone)
{
String desc = config.getOptional("_command", String.class).or(() -> config.get("at", String.class));
String[] fragments = desc.split(",", 2);
if (fragments.length != 2) {
throw new ConfigException("weekly>: scheduler requires day,hh:mm:ss format: " + desc);
}
String day = fragments[0].trim();
String time = fragments[1].trim();
// cron4j incorrectly parses negative day of week as positive.
try {
int dayNumber = Integer.parseInt(day);
if (dayNumber < 0) {
throw new ConfigException("weekly>: invalid day: " + day);
}
} catch (NumberFormatException ignore) {
// Not an integer, validate using SchedulingPattern.validate.
}
long dailyDelay = parseAt("weekly>", time);
String cronPattern = "0 0 * * " + day;
boolean valid = SchedulingPattern.validate(cronPattern);
if (!valid) {
throw new ConfigException("weekly>: scheduler requires day,hh:mm:ss format: " + desc);
}
return new CronScheduler(cronPattern, timeZone, dailyDelay);
}
示例4: getNextScheduledTime
import it.sauronsoftware.cron4j.SchedulingPattern; //导入方法依赖的package包/类
public static Date getNextScheduledTime(String cronExp, String timeZone){
Date nextScheduledTime = null;
if (cronExp!=null && SchedulingPattern.validate(cronExp)) {
Predictor predictor = new Predictor(cronExp);
predictor.setTimeZone(TimeZone.getTimeZone(timeZone));
nextScheduledTime = predictor.nextMatchingDate();
}
return nextScheduledTime;
}