diff --git a/redisson/src/main/java/org/redisson/RedissonExecutorService.java b/redisson/src/main/java/org/redisson/RedissonExecutorService.java index 1efc9efc9..375f4b12c 100644 --- a/redisson/src/main/java/org/redisson/RedissonExecutorService.java +++ b/redisson/src/main/java/org/redisson/RedissonExecutorService.java @@ -815,7 +815,7 @@ public class RedissonExecutorService implements RScheduledExecutorService { throw new IllegalArgumentException("Wrong cron expression! Unable to calculate start date"); } long startTime = startDate.getTime(); - RemotePromise result = (RemotePromise) asyncScheduledServiceAtFixed.schedule(task.getClass().getName(), classBody, state, startTime, cronSchedule.getExpression(), executorId, null); + RemotePromise result = (RemotePromise) asyncScheduledServiceAtFixed.schedule(task.getClass().getName(), classBody, state, startTime, cronSchedule.getExpression().getCronExpression(),cronSchedule.getExpression().getTimeZone().getID(), executorId, null); addListener(result); RedissonScheduledFuture f = new RedissonScheduledFuture(result, startTime) { public long getDelay(TimeUnit unit) { diff --git a/redisson/src/main/java/org/redisson/executor/RemoteExecutorService.java b/redisson/src/main/java/org/redisson/executor/RemoteExecutorService.java index 6ecd1b17f..0a697c16d 100644 --- a/redisson/src/main/java/org/redisson/executor/RemoteExecutorService.java +++ b/redisson/src/main/java/org/redisson/executor/RemoteExecutorService.java @@ -34,6 +34,6 @@ public interface RemoteExecutorService { void scheduleWithFixedDelay(String className, byte[] classBody, byte[] state, long startTime, long delay, String executorId, String requestId); - void schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId); + void schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String timezone, String executorId, String requestId); } diff --git a/redisson/src/main/java/org/redisson/executor/RemoteExecutorServiceAsync.java b/redisson/src/main/java/org/redisson/executor/RemoteExecutorServiceAsync.java index dde2d2bab..f4417d6d6 100644 --- a/redisson/src/main/java/org/redisson/executor/RemoteExecutorServiceAsync.java +++ b/redisson/src/main/java/org/redisson/executor/RemoteExecutorServiceAsync.java @@ -38,6 +38,6 @@ public interface RemoteExecutorServiceAsync { RFuture scheduleWithFixedDelay(String className, byte[] classBody, byte[] state, long startTime, long delay, String executorId, String requestId); - RFuture schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId); + RFuture schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String timezone, String executorId, String requestId); } diff --git a/redisson/src/main/java/org/redisson/executor/TasksRunnerService.java b/redisson/src/main/java/org/redisson/executor/TasksRunnerService.java index 67bfba7ec..dd4f42d80 100644 --- a/redisson/src/main/java/org/redisson/executor/TasksRunnerService.java +++ b/redisson/src/main/java/org/redisson/executor/TasksRunnerService.java @@ -40,6 +40,7 @@ import org.redisson.remote.ResponseEntry; import java.io.IOException; import java.util.Arrays; import java.util.Date; +import java.util.TimeZone; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; @@ -118,12 +119,14 @@ public class TasksRunnerService implements RemoteExecutorService { } @Override - public void schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId) { - Date nextStartDate = cronExpression.getNextValidTimeAfter(new Date()); + public void schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String timezone, String executorId, String requestId) { + CronExpression expression = new CronExpression(cronExpression); + expression.setTimeZone(TimeZone.getTimeZone(timezone)); + Date nextStartDate = expression.getNextValidTimeAfter(new Date()); RFuture future = null; if (nextStartDate != null) { RemoteExecutorServiceAsync service = asyncScheduledServiceAtFixed(executorId, requestId); - future = service.schedule(className, classBody, state, nextStartDate.getTime(), cronExpression, executorId, requestId); + future = service.schedule(className, classBody, state, nextStartDate.getTime(), cronExpression, timezone, executorId, requestId); } try { executeRunnable(className, classBody, state, requestId);