Filipp Zhinkin
08/15/2025, 5:38 PM2.1.20
Instant
and Clock
from kotlinx-datetime
were added (and slightly modified along the way) to the standard library as kotlin.time.Instant and kotlin.time.Clock and remained experimental since then. There were almost no feedback on these types (except how painful was the removal of corresponding classes from the datetime library), so they are candidates for stabilization in 2.3
.
Please let us know if there are any issues with kotlin.time.Instant
and kotlin.time.Clock
API or implementation, so it could be updated before stabilization, if needed. Thanks!Robert Jaros
08/15/2025, 6:28 PMkotlin.time.*
and java.time.*
on the JVM target? If it only concerned an external library like kotlinx-datetime
it would be understandable - it's just some API and there are other libs out there. But putting that in the stdlib is a "one way trip". We will end up converting between Kotlin to Java all over our code forever. It reminds me Scala's collections.Robert Jaros
08/15/2025, 6:30 PMkevin.cianfarini
08/15/2025, 7:28 PMkevin.cianfarini
08/15/2025, 7:29 PMFilipp Zhinkin
08/15/2025, 7:30 PMInstant
to java.time.Instant
here: https://github.com/Kotlin/KEEP/blob/main/proposals/stdlib/KEEP-0395-instant.md#implementation-on-the-jvm
Briefly, the main reason for not doing that, is that kotlin.time.Instant
(or, kotlinx.datetime.Instant
back then) behavior diverges from java.time.Instant
.Filipp Zhinkin
08/15/2025, 7:34 PMkevin.cianfarini
08/15/2025, 7:39 PMval staticClock = Clock { myInstant }
I don't think this could be a fun interface
for api compatibility reasons, but a function could be added which mimic it maybe?
fun Clock(provider: () -> Instant): Clock = object : Clock {
override fun now() = provider()
}
kevin.cianfarini
08/15/2025, 7:40 PMkevin.cianfarini
08/15/2025, 7:49 PMCLOVIS
08/18/2025, 1:57 PM