当前位置: 首页>>代码示例>>Java>>正文


Java SchedulingPattern.validate方法代码示例

本文整理汇总了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;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:31,代码来源:MScheduler.java

示例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;
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:9,代码来源:VerifyController.java

示例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);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:34,代码来源:WeeklySchedulerFactory.java

示例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;		
}
 
开发者ID:smrjan,项目名称:job4j,代码行数:10,代码来源:CronUtil.java


注:本文中的it.sauronsoftware.cron4j.SchedulingPattern.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。