Dmitry Khalanskiy [JB]
06/30/2025, 11:46 AMkotlinx-datetime
0.6.2 or earlier, and are also
2. Planning on upgrading to kotlinx-datetime
0.7.0, but haven't yet,
then you are advised to wait until 0.7.1 comes out in the next few days.
0.7.0 is missing some migration assistance, namely the deprecated-with-warning type aliases kotlinx.datetime.Instant = kotlin.time.Instant
and kotlinx.datetime.Clock = kotlin.time.Clock
(https://github.com/Kotlin/kotlinx-datetime/pull/540/commits/f829958a1bcbe7b24a11a91519cf57aaf3daa74b). Without them, your client code will not compile until you replace the usages manually, whereas with them, you will be able to proceed at your own pace (if you are not using libraries that themselves depend on kotlinx.datetime.Instant
) or even perform automatic replacement with the help of an IDE.
This is a glaring omission that I made when publishing the release, and I am sorry about that. The type aliases in 0.7.0 were planned from the beginning, but due to my oversight, were missing from the release.Jacob Ras
06/30/2025, 4:07 PMEmre
06/30/2025, 7:00 PMDmitry Khalanskiy [JB]
06/30/2025, 8:33 PMrocketraman
07/07/2025, 3:09 PMDmitry Khalanskiy [JB]
07/07/2025, 4:03 PMkotlinx.datetime.Instant
and kotlin.time.Instant
as basically the same thing. kotlinx.datetime.Instant
will not have its own representation in the compiled file.
This means that libraries compiled with the existence of kotlinx.datetime.Instant
in mind will not work with the plain 0.7.1 and will instead throw ClassNotFoundException
when an attempt to access kotlinx.datetime.Instant
is made. After all, the class truly does not exist as a separate entity.
The compatibility artifact has kotlinx.datetime.Instant
as a proper class, which has many usability downsides, but preserves compatibility with libraries not yet recompiled with kotlinx-datetime
0.7.x.rocketraman
07/07/2025, 5:01 PMrocketraman
07/07/2025, 5:10 PMDmitry Khalanskiy [JB]
07/07/2025, 5:16 PMkotlin.time.Instant
but not kotlinx.datetime.Instant
, whereas others only have kotlinx.datetime.Instant
but not kotlin.time.Instant
, then you have to do some runtime check like try { println(kotlinx.datetime.Instant.fromEpochSeconds(0)) } catch (e: ClassNotFoundException) { println(kotlin.time.Instant.fromEpochSeconds(0)) }
for every usage. You will also need to have a compile-only dependency on Kotlin 2.1.20 and a compile-only dependency on the compatibility artifact of kotlinx-datetime
.rocketraman
07/07/2025, 5:24 PMDmitry Khalanskiy [JB]
07/07/2025, 5:25 PM