Preserve milliseconds in build info timestamp
See gh-43612
This commit is contained in:
@@ -88,7 +88,7 @@ class MavenBuildOutputTimestamp {
|
||||
try {
|
||||
Instant instant = OffsetDateTime.parse(this.timestamp)
|
||||
.withOffsetSameInstant(ZoneOffset.UTC)
|
||||
.truncatedTo(ChronoUnit.SECONDS)
|
||||
.truncatedTo(ChronoUnit.MILLIS)
|
||||
.toInstant();
|
||||
if (instant.isBefore(DATE_MIN) || instant.isAfter(DATE_MAX)) {
|
||||
throw new IllegalArgumentException(
|
||||
|
||||
@@ -52,8 +52,13 @@ class MavenBuildOutputTimestampTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseIso8601WithMilliseconds() {
|
||||
assertThat(parse("2011-12-03T10:15:30.12345Z")).isEqualTo(Instant.parse("2011-12-03T10:15:30Z"));
|
||||
void shouldParseIso8601WithSeconds_whenMillisecondsNotPresent() {
|
||||
assertThat(parse("2011-12-03T10:15:30Z")).isEqualTo(Instant.parse("2011-12-03T10:15:30Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseIso8601WithMillisecondsPreserved_whenPresent() {
|
||||
assertThat(parse("2024-12-19T19:59:39.040Z")).isEqualTo(Instant.parse("2024-12-19T19:59:39.040Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user