Skip to content

Commit

Permalink
test: revert change to UTC formatting in unit tests
Browse files Browse the repository at this point in the history
This change formats iso timestamps using JVM date
formatting in order to compare with the output from
log4j date formatting.
  • Loading branch information
dekobon committed Dec 14, 2021
1 parent 37dccd8 commit 519c88d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/test/java/log4j/layout/bunyan/LogOutputTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -255,8 +258,8 @@ void validateEvent(final LogEvent event, final String json) throws IOException {
}

static String formatAsUTCTimestamp(final long epochMillis) {
StringBuilder buffer = new StringBuilder();
DatePatternConverterFactory.instance().format(epochMillis, buffer);
return buffer.toString();
final Instant instant = Instant.ofEpochMilli(epochMillis);
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC)
.format(DateTimeFormatter.ISO_INSTANT);
}
}

0 comments on commit 519c88d

Please sign in to comment.