I'm having a hard time finding documentation on how to deserialize date fields. How do i achieve this? Most solutions i found on SO don't work or they use classes that are no longer available
@Serializable
data class Dashboard(
val someNumber: Int,
val someDate: Date? // Custom Deserialization from unix timestamp
)
EDIT: Most solution i found use PrimitiveSerialDescriptor which seems to be not available
Do not use Date, but use Instant or LocalDateTime instead, you need to add this in build.gradle file
implementation "org.jetbrains.kotlinx:kotlinx-datetime:0.3.2"
read more about it in this link: https://github.com/Kotlin/kotlinx-datetime
This will automatically Serializable and also work in KMM š
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With