List of usage examples for org.joda.time Minutes isGreaterThan
public boolean isGreaterThan(Minutes other)
From source file:org.artifactory.cron.CronUtils.java
License:Open Source License
/** * Checks if the given cron expression interval is less or equals to a certain minimum. * * @param cronExpression the cron expression to check *//*w w w .j a va 2s .c o m*/ public static boolean isCronIntervalLessThanMinimum(String cronExpression) { try { // If input is empty or invalid simply return false as default if (StringUtils.isBlank(cronExpression) || !isValid(cronExpression)) { return false; } CronExpression cron = new CronExpression(cronExpression); final Date firstExecution = cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); final Date secondExecution = cron.getNextValidTimeAfter(firstExecution); Minutes intervalMinutes = Minutes.minutesBetween(new DateTime(firstExecution), new DateTime(secondExecution)); return !intervalMinutes.isGreaterThan(MINIMUM_ALLOWED_MINUTES); } catch (ParseException e) { throw new IllegalArgumentException(e.getMessage()); } }