mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 05:55:39 +03:00
add KotlinxJodaTimeConverter
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
a576e5f41c
commit
3d7a72f189
1 changed files with 22 additions and 0 deletions
|
@ -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<DateTime> {
|
||||
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())
|
||||
|
||||
}
|
Loading…
Reference in a new issue