Skip to content

Commit 0944b07

Browse files
gavaravasnicoll
authored andcommitted
Preserve milliseconds in build info timestamp
See gh-43612
1 parent b589313 commit 0944b07

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MavenBuildOutputTimestamp.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Instant toInstant() {
8888
try {
8989
Instant instant = OffsetDateTime.parse(this.timestamp)
9090
.withOffsetSameInstant(ZoneOffset.UTC)
91-
.truncatedTo(ChronoUnit.SECONDS)
91+
.truncatedTo(ChronoUnit.MILLIS)
9292
.toInstant();
9393
if (instant.isBefore(DATE_MIN) || instant.isAfter(DATE_MAX)) {
9494
throw new IllegalArgumentException(

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/MavenBuildOutputTimestampTests.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ void shouldParseIso8601() {
5252
}
5353

5454
@Test
55-
void shouldParseIso8601WithMilliseconds() {
56-
assertThat(parse("2011-12-03T10:15:30.12345Z")).isEqualTo(Instant.parse("2011-12-03T10:15:30Z"));
55+
void shouldParseIso8601WithSeconds_whenMillisecondsNotPresent() {
56+
assertThat(parse("2011-12-03T10:15:30Z")).isEqualTo(Instant.parse("2011-12-03T10:15:30Z"));
57+
}
58+
59+
@Test
60+
void shouldParseIso8601WithMillisecondsPreserved_whenPresent() {
61+
assertThat(parse("2024-12-19T19:59:39.040Z")).isEqualTo(Instant.parse("2024-12-19T19:59:39.040Z"));
5762
}
5863

5964
@Test

0 commit comments

Comments
 (0)