Skip to content

Commit 78ea42e

Browse files
committed
use iso8601
1 parent e1728ae commit 78ea42e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/jvmMain/kotlin/spp/protocol/marshall/KSerializers.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import kotlinx.datetime.Instant
3030
object KSerializers {
3131
class KotlinInstantSerializer : JsonSerializer<Instant>() {
3232
override fun serialize(value: Instant, jgen: JsonGenerator, provider: SerializerProvider) =
33-
jgen.writeString(value.toEpochMilliseconds().toString())
33+
jgen.writeString(value.toString())
3434
}
3535

3636
class KotlinInstantDeserializer : JsonDeserializer<Instant>() {
3737
override fun deserialize(p: JsonParser, p1: DeserializationContext): Instant =
38-
Instant.fromEpochMilliseconds((p.codec.readTree(p) as JsonNode).asText().toLong())
38+
Instant.parse((p.codec.readTree(p) as JsonNode).asText())
3939
}
4040
}

src/jvmMain/kotlin/spp/protocol/marshall/ProtocolMarshaller.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ object ProtocolMarshaller {
247247
deserializeLiveInstrument(value.getJsonObject("liveInstrument")),
248248
value.let {
249249
if (it.getValue("occurredAt") is String) {
250-
Instant.fromEpochMilliseconds(value.getString("occurredAt").toLong())
250+
Instant.parse(value.getString("occurredAt"))
251251
} else if (it.getValue("occurredAt") is Number) {
252252
Instant.fromEpochMilliseconds(value.getLong("occurredAt"))
253253
} else {
@@ -303,7 +303,7 @@ object ProtocolMarshaller {
303303
value.getString("traceId"),
304304
value.let {
305305
if (it.getValue("occurredAt") is String) {
306-
Instant.fromEpochMilliseconds(value.getString("occurredAt").toLong())
306+
Instant.parse(value.getString("occurredAt"))
307307
} else if (it.getValue("occurredAt") is Number) {
308308
Instant.fromEpochMilliseconds(value.getLong("occurredAt"))
309309
} else {
@@ -331,7 +331,7 @@ object ProtocolMarshaller {
331331
LogOrderType.valueOf(value.getString("orderType")),
332332
value.let {
333333
if (it.getValue("timestamp") is String) {
334-
Instant.fromEpochMilliseconds(value.getString("occurredAt").toLong())
334+
Instant.parse(value.getString("timestamp"))
335335
} else if (it.getValue("timestamp") is Number) {
336336
Instant.fromEpochMilliseconds(value.getLong("timestamp"))
337337
} else {
@@ -363,7 +363,7 @@ object ProtocolMarshaller {
363363
value.getString("logId"),
364364
value.let {
365365
if (it.getValue("occurredAt") is String) {
366-
Instant.fromEpochMilliseconds(value.getString("occurredAt").toLong())
366+
Instant.parse(value.getString("occurredAt"))
367367
} else if (it.getValue("occurredAt") is Number) {
368368
Instant.fromEpochMilliseconds(value.getLong("occurredAt"))
369369
} else {
@@ -389,7 +389,7 @@ object ProtocolMarshaller {
389389
return Log(
390390
value.let {
391391
if (it.getValue("timestamp") is String) {
392-
Instant.fromEpochMilliseconds(value.getString("occurredAt").toLong())
392+
Instant.parse(value.getString("timestamp"))
393393
} else if (it.getValue("timestamp") is Number) {
394394
Instant.fromEpochMilliseconds(value.getLong("timestamp"))
395395
} else {

0 commit comments

Comments
 (0)