From 3640491d5aa144eecbfbeb001658f6155ec8431c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 30 Aug 2023 19:58:00 -0700 Subject: [PATCH] Fix Timezone used for now in BuildRequestTests --- .../boot/buildpack/platform/build/BuildRequestTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildRequestTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildRequestTests.java index 1ded1fa5261..e74302a1636 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildRequestTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/BuildRequestTests.java @@ -53,6 +53,8 @@ import static org.assertj.core.api.Assertions.entry; */ class BuildRequestTests { + private static final ZoneId UTC = ZoneId.of("UTC"); + @TempDir File tempDir; @@ -271,15 +273,15 @@ class BuildRequestTests { @Test void withCreatedDateNowSetsCreatedDate() throws Exception { - OffsetDateTime now = OffsetDateTime.now(); + OffsetDateTime now = OffsetDateTime.now(UTC); BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar")); BuildRequest withCreatedDate = request.withCreatedDate("now"); - OffsetDateTime createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), ZoneId.of("UTC")); + OffsetDateTime createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), UTC); assertThat(createdDate.getYear()).isEqualTo(now.getYear()); assertThat(createdDate.getMonth()).isEqualTo(now.getMonth()); assertThat(createdDate.getDayOfMonth()).isEqualTo(now.getDayOfMonth()); withCreatedDate = request.withCreatedDate("NOW"); - createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), ZoneId.of("UTC")); + createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), UTC); assertThat(createdDate.getYear()).isEqualTo(now.getYear()); assertThat(createdDate.getMonth()).isEqualTo(now.getMonth()); assertThat(createdDate.getDayOfMonth()).isEqualTo(now.getDayOfMonth());