Hello,
not sure if this is the best place to post the question, but here we go:
Is there a way to define the resolution that Kotlin uses for `Instant`s?
Reason: Our Kotlin application talks to a PostgreSQL database and saves `Instant`s in a
timestamp
column.
PostgreSQL has microsecond resolution for that column.
On MacOS, this works because
Clock.System.now()
also returns an
Instant
with microsecond resolution, so comparing an object before persisting it and after retrieving it from the database works.
On Linux (which we use for our pipeline) this same comparison fails because
2023-06-09T07:34:27.965341799Z != 2023-06-09T07:34:27.965342Z
I found similar issues for e.g. H2, but there it seems possible to simply store nanoseconds in the database.
It is not necessarily an issue to change the tests, we can simply set fixed instants (without nanosecond precision), but the question remains nevertheless:
Is there a way to force Kotlin to always use a specific precision?