diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/KotlinxJodaTimeConverter.kt b/app/src/main/java/com/nextcloud/talk/models/json/converters/KotlinxJodaTimeConverter.kt new file mode 100644 index 000000000..efb539fb3 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/KotlinxJodaTimeConverter.kt @@ -0,0 +1,22 @@ +package com.nextcloud.talk.models.json.converters + +import kotlinx.serialization.KSerializer +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import org.joda.time.DateTime + +object KotlinxJodaTimeConverter : KSerializer { + override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("DateTime", PrimitiveKind.STRING) + + override fun serialize(encoder: Encoder, value: DateTime) { + encoder.encodeString(value.toString()) + } + + override fun deserialize(decoder: Decoder): DateTime = + DateTime.parse(decoder.decodeString()) + +}