java.lang.Object | |
↳ | com.atlassian.jira.scheduler.cron.SimpleToCronTriggerConverter |
From
the extranet spec page:
There are a number of things a cronspec cannot handle cleanly when converting a arbitrary fixed millisecond repeat
from a specific DateTime into a cronspec. Things such as "every 15 min from 9.53am Jan 23rd 2006" (closest cronspec
would be "every 15min").
Basic parsing rules for the algorithm are that the main Unit that will be used is the largest unit it is close to
(minutes, hours, days, week, months) and then rounded to the nearest neighbour that is a denominator of the next
largest unit. So an unit of 5 hours is specified in hours, but as 5 is not a denominator of 24 it must be rounded
to 4 or 6. Similarly 15 hours would be rounded down to 12 and 20 hours would be rounded up to 24 (daily).
Once the time period is specified as a number of days there are some fairly intractable issues. Firstly, the number of days in a week - 7 - is prime and has no denominators apart from 1 and itself, and months may have 28, 29, 30 or 31 days so exact arithmetic is not possible. For these periods we will need to round periods above 7 days and up to 15 days down to 7 days, and of over 15 days to one month. Multi-month periods can be supported in the 2, 3, 4, 6 and 12 month periods. We will not support multi-year periods and any currently specified will be rounded down to a single year period.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Converts trigger data taken from the database entries into a
quartz CronTrigger String.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the time unit (SECONDS, MINUTES, MONTHS etc.) that the supplied interval (ms) is closest to.
| |||||||||||
Given a unit of time (e.g.
| |||||||||||
Make a cron element of the form 'START_TIME''/''FREQUENCY'.
| |||||||||||
Round the interval to the nearest time unit multiple that is a denominator of the succeeding time unit.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object |
Converts trigger data taken from the database entries into a quartz CronTrigger String. Note that this conversion is sometimes lossy. Not all inputs can result in an equivalent cron string such that the triggers will fire at the same time.
nextFireDate | a time a trigger will next fire |
---|---|
intervalMs | a time delay in milliseconds between trigger firing |
ConversionResult
which contains composed of the following cron fields:Return the time unit (SECONDS, MINUTES, MONTHS etc.) that the supplied interval (ms) is closest to.
intervalMs | the supplied interval in milliseconds |
---|
Given a unit of time (e.g. MINUTES), this method returns the next unit of time from the unit of time sequence (e.g. HOURS).
timeUnit | a unit of time, defined at the top of this class |
---|
Make a cron element of the form 'START_TIME''/''FREQUENCY'.
In order for the trigger to fire the right number of times, we must pick the earliest possible start time where START_TIME + N * FREQUENCY = TARGET_TIME, where N is some positive integer, holds true.
targetTime | The time that the trigger should fire on, parsed from the nextFire quartz trigger field |
---|---|
frequency | The delay between trigger firings |
base | The base of the cron timeunit: 0 or 1. Seconds [0-59], minutes [0-59] & hours [0-23] are zero-based. Day of Month [1-31], Months [1-12] and Days of Week [1-7] are one-based. |
Round the interval to the nearest time unit multiple that is a denominator of the succeeding time unit. That is, find the set of intervals in milliseconds that satisfies the following:
intervalMs | the original interval in milliseconds |
---|---|
baseTimeUnit | the time unit that is the major component of the cron string (e.g. SECONDS, HOURS, etc.) |