Skip to content

Enable implicit conversion from kotlin.time.Duration to java.time.Duration #683

@kkurczewski

Description

@kkurczewski

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions