mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-26 08:59:09 +00:00
Modernize java.time API usages
See gh-35861 Signed-off-by: Vincent Potucek <vpotucek@me.com>
This commit is contained in:
committed by
Sébastien Deleuze
parent
3686b89ab5
commit
83bbf16e6c
+1
-2
@@ -81,8 +81,7 @@ final class DateTimeConverters {
|
||||
return gc.toZonedDateTime();
|
||||
}
|
||||
else {
|
||||
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(source.getTimeInMillis()),
|
||||
source.getTimeZone().toZoneId());
|
||||
return Instant.ofEpochMilli(source.getTimeInMillis()).atZone(source.getTimeZone().toZoneId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ public class CronTrigger implements Trigger {
|
||||
public @Nullable Instant nextExecution(TriggerContext triggerContext) {
|
||||
Instant timestamp = determineLatestTimestamp(triggerContext);
|
||||
ZoneId zone = (this.zoneId != null ? this.zoneId : triggerContext.getClock().getZone());
|
||||
ZonedDateTime zonedTimestamp = ZonedDateTime.ofInstant(timestamp, zone);
|
||||
ZonedDateTime zonedTimestamp = timestamp.atZone(zone);
|
||||
ZonedDateTime nextTimestamp = this.expression.next(zonedTimestamp);
|
||||
return (nextTimestamp != null ? nextTimestamp.toInstant() : null);
|
||||
}
|
||||
|
||||
+4
-5
@@ -18,7 +18,6 @@ package org.springframework.scheduling.concurrent;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -53,28 +52,28 @@ class DefaultManagedTaskSchedulerTests {
|
||||
void scheduleAtFixedRateWithStartTimeAndDurationAndNoScheduledExecutorProvidesDedicatedException() {
|
||||
DefaultManagedTaskScheduler scheduler = new DefaultManagedTaskScheduler();
|
||||
assertNoExecutorException(() -> scheduler.scheduleAtFixedRate(
|
||||
NO_OP, Instant.now(), Duration.of(1, ChronoUnit.MINUTES)));
|
||||
NO_OP, Instant.now(), Duration.ofMinutes(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void scheduleAtFixedRateWithDurationAndNoScheduledExecutorProvidesDedicatedException() {
|
||||
DefaultManagedTaskScheduler scheduler = new DefaultManagedTaskScheduler();
|
||||
assertNoExecutorException(() -> scheduler.scheduleAtFixedRate(
|
||||
NO_OP, Duration.of(1, ChronoUnit.MINUTES)));
|
||||
NO_OP, Duration.ofMinutes(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void scheduleWithFixedDelayWithStartTimeAndDurationAndNoScheduledExecutorProvidesDedicatedException() {
|
||||
DefaultManagedTaskScheduler scheduler = new DefaultManagedTaskScheduler();
|
||||
assertNoExecutorException(() -> scheduler.scheduleWithFixedDelay(
|
||||
NO_OP, Instant.now(), Duration.of(1, ChronoUnit.MINUTES)));
|
||||
NO_OP, Instant.now(), Duration.ofMinutes(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void scheduleWithFixedDelayWithDurationAndNoScheduledExecutorProvidesDedicatedException() {
|
||||
DefaultManagedTaskScheduler scheduler = new DefaultManagedTaskScheduler();
|
||||
assertNoExecutorException(() -> scheduler.scheduleWithFixedDelay(
|
||||
NO_OP, Duration.of(1, ChronoUnit.MINUTES)));
|
||||
NO_OP, Duration.ofMinutes(1)));
|
||||
}
|
||||
|
||||
private void assertNoExecutorException(ThrowingCallable callable) {
|
||||
|
||||
Reference in New Issue
Block a user