Use TriggerContext's Clock instead of new Date()

Closes gh-27546
This commit is contained in:
Juergen Hoeller 2021-10-12 15:17:18 +02:00
parent 715f300fa1
commit e4934a90eb
1 changed files with 3 additions and 3 deletions

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -105,11 +105,11 @@ public class CronTrigger implements Trigger {
} }
} }
else { else {
date = new Date(); date = new Date(triggerContext.getClock().millis());
} }
ZonedDateTime dateTime = ZonedDateTime.ofInstant(date.toInstant(), this.zoneId); ZonedDateTime dateTime = ZonedDateTime.ofInstant(date.toInstant(), this.zoneId);
ZonedDateTime next = this.expression.next(dateTime); ZonedDateTime next = this.expression.next(dateTime);
return next != null ? Date.from(next.toInstant()) : null; return (next != null ? Date.from(next.toInstant()) : null);
} }