-
-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Use case
Usage of kotlin.time.Duration
instead of java.time.Duration
in Kotlin projects
Describe the solution you'd like
My proposal is to add additional serialization option like: KotlinSerializationFeature.SERIALIZE_KOTLIN_DURATION_AS_JAVA_DURATION
.
It would call kotlin.time.Duration.toJavaDuration()
under hood and allow to reuse all features already implemented for java.time.Duration
. It could be disabled by default to keep backward compatibility.
Describe alternatives you've considered
I can implement custom de/serializers or write custom KotlinTimeModule
etc. While it is not a big deal downside of this is that implementation would be very similar (identical?) for everyone and has to be copy-pasted over all projects therefore I think it is a good fit for library.