/** * Used to validate the hours to see that the from hour is before the to hour, if specified. * Note: to allow the range to run "all-day" (eg. from 12AM to 12AM), we need to also allow the from and to times to * be equal. * * @return true if from is before to or if they have not been specified. */ public boolean isRangeHoursValid() { if (hoursFrom != null && hoursFromMeridian != null && hoursTo != null && hoursToMeridian != null && incrementInMinutes != null && !incrementInMinutes.equals("0")) { try { int hoursFromInt = Integer.parseInt(hoursFrom); int hoursToInt = Integer.parseInt(hoursTo); return JiraUtils.get24HourTime(hoursFromMeridian, hoursFromInt) <= JiraUtils.get24HourTime(hoursToMeridian, hoursToInt); } catch (NumberFormatException e) { // Something is freaky with the hours, hmmmm.... return false; } } return true; }
/** * Indicates that the range of time specified spans across the full 24 hours in a day (which is indicated by the * computed hoursFrom in 24 hour time being equal to the computed hoursTo in 24 hour time). * * @return true only if we have specified a range, and that range spans across the 24 hours. */ public boolean is24HourRange() { boolean result = false; if (isRange()) { int hoursFromInt = Integer.parseInt(hoursFrom); int hoursToInt = Integer.parseInt(hoursTo); result = JiraUtils.get24HourTime(hoursFromMeridian, hoursFromInt) == JiraUtils.get24HourTime(hoursToMeridian, hoursToInt); } return result; }
int atMins = getIntFromString(cronEditorBean.getMinutes()); atHours = JiraUtils.get24HourTime(cronEditorBean.getHoursRunOnceMeridian(), atHours); int fromHours = JiraUtils.get24HourTime(cronEditorBean.getHoursFromMeridian(), getIntFromString(cronEditorBean.getHoursFrom())); int toHours = JiraUtils.get24HourTime(cronEditorBean.getHoursToMeridian(), getIntFromString(cronEditorBean.getHoursTo()));