Skip to content
Browse files
Add timezone support to recurring job temporal expressions

When try to define a temporal expression for a recurring job where the temporal expression should be evaluated using a timezone other than whatever the default timezone is for the system.

The use case is having a system that runs on UTC time but needs to send a report at 5 pm Pacific Time every day regardless of whether or not daylight savings is in effect.

To do this:

Added a new field to JobSandbox such as recurrenceTimeZone and modified code to use this timeZone if available.

Thanks: Scott Gray for reporting and Nicolas Malin for the review.

git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Pawan Verma committed Sep 6, 2019
1 parent 8cc48ec commit 968515cf07252a666fcf50d498b883d4812b989d
Showing with 5 additions and 1 deletion.
  1. +1 −0 framework/service/entitydef/entitymodel.xml
  2. +4 −1 framework/service/src/main/java/org/apache/ofbiz/service/job/
@@ -65,6 +65,7 @@ under the License.
<field name="finishDateTime" type="date-time"></field>
<field name="cancelDateTime" type="date-time"></field>
<field name="jobResult" type="value"></field>
<field name="recurrenceTimeZone" type="id-long"/>
<prim-key field="jobId"/>
<relation type="one" fk-name="JOB_SNDBX_RECINFO" rel-entity-name="RecurrenceInfo">
<key-map field-name="recurrenceInfoId"/>
@@ -49,6 +49,7 @@
import org.xml.sax.SAXException;


* A {@link Job} that is backed by the entity engine. Job data is stored
@@ -175,7 +176,9 @@ protected void init() throws InvalidJobException {
if (recurrence != null) {
Calendar next =;
TimeZone timeZone = jobValue.get("recurrenceTimeZone") != null ? TimeZone.getTimeZone(jobValue.getString("recurrenceTimeZone")) : TimeZone.getDefault();
Calendar next =;

if (next != null) {
createRecurrence(next.getTimeInMillis(), false);

0 comments on commit 968515c

Please sign in to comment.