Skip to content

Commit

Permalink
fix: remove JavaTimeModule from jackson parser to not require java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Kolstad committed Sep 8, 2021
1 parent 801d5c2 commit f47186b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/kotlin/io/getunleash/data/Parser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
5 changes: 3 additions & 2 deletions src/test/kotlin/io/getunleash/metrics/MetricsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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\"")
}

}

0 comments on commit f47186b

Please sign in to comment.