If all timestamps that I receive from an API in my...
# kotlinx-datetime
e
If all timestamps that I receive from an API in my application use a non ISO 8601 extended format, is there a way I can globally use a custom serializer anywhere I use
Instant
, or do I have to annotate it with
Contextual
/
Serializable(with)
on every occurrence?
e
@UseSerializers is per-file
e
This would be project wide though. Multiple files across multiple modules.
I guess I could use a value type that wraps Instant 🤔
e
in my work project, we have a custom Android Lint rule with autofix to add
@file:UseSerializer(...)
if the use sites weren't annotated, and it seems to work well enough for us
yeah it's not quite global, but it's easier than the alternatives
c
> I guess I could use a value type that wraps Instant 🤔
Copy code
typealias MyInstant = @Serializable(with = xxx) Instant
works, it doesn't need to be a full custom type
👀 2
😯 1