From e4934a90ebf22adfde31a8e44b32d88cae5ed7c1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 12 Oct 2021 15:17:18 +0200 Subject: [PATCH] Use TriggerContext's Clock instead of new Date() Closes gh-27546 --- .../org/springframework/scheduling/support/CronTrigger.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java b/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java index 3af71481c2..6581cdd61f 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/CronTrigger.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,11 +105,11 @@ public class CronTrigger implements Trigger { } } else { - date = new Date(); + date = new Date(triggerContext.getClock().millis()); } ZonedDateTime dateTime = ZonedDateTime.ofInstant(date.toInstant(), this.zoneId); ZonedDateTime next = this.expression.next(dateTime); - return next != null ? Date.from(next.toInstant()) : null; + return (next != null ? Date.from(next.toInstant()) : null); }