From f47186b559571c1d7ed739bba235a1ac11d11f4e Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Wed, 8 Sep 2021 08:38:33 +0200 Subject: [PATCH] fix: remove JavaTimeModule from jackson parser to not require java 8 --- src/main/kotlin/io/getunleash/data/Parser.kt | 3 +-- src/test/kotlin/io/getunleash/metrics/MetricsTest.kt | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/io/getunleash/data/Parser.kt b/src/main/kotlin/io/getunleash/data/Parser.kt index 9c5b38b..70b0bf9 100644 --- a/src/main/kotlin/io/getunleash/data/Parser.kt +++ b/src/main/kotlin/io/getunleash/data/Parser.kt @@ -3,12 +3,11 @@ package io.getunleash.data import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.util.StdDateFormat -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper object Parser { val jackson: ObjectMapper = - jacksonObjectMapper().registerModule(JavaTimeModule()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + jacksonObjectMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .setDateFormat( StdDateFormat().withColonInTimeZone(true) ) diff --git a/src/test/kotlin/io/getunleash/metrics/MetricsTest.kt b/src/test/kotlin/io/getunleash/metrics/MetricsTest.kt index 0f9f427..b4606b6 100644 --- a/src/test/kotlin/io/getunleash/metrics/MetricsTest.kt +++ b/src/test/kotlin/io/getunleash/metrics/MetricsTest.kt @@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test import java.io.File import java.time.ZoneOffset import java.time.ZonedDateTime +import java.util.Date class MetricsTest { @@ -161,8 +162,8 @@ class MetricsTest { @Test fun `bucket start and stop gets reported in ISO 8601 format`() { - val output = Parser.jackson.writeValueAsString(ZonedDateTime.of(2021, 6, 1, 15, 0, 0, 456000000, ZoneOffset.UTC).toInstant()) - assertThat(output).isEqualTo("\"2021-06-01T15:00:00.456Z\"") + val output = Parser.jackson.writeValueAsString(Date.from(ZonedDateTime.of(2021, 6, 1, 15, 0, 0, 456000000, ZoneOffset.UTC).toInstant())) + assertThat(output).isEqualTo("\"2021-06-01T15:00:00.456+00:00\"") } } \ No newline at end of file