Kotlin-multiplatform timestamp to time in milliseconds (unix time)

I’m using kotlin-multiplatform for iOS and Android targets.

I’m deserializing json string with timestamp inside: 2020-01-16T11:33:34.553Z

I would like to convert this timestamp to time in milliseconds (unix time). Is it possible to do this using kotlin native libraries?

I’m using kotlin multiplatform 1.3.72.

You have not well-defined your issue, but I believe what you need is a multiplatform library to handle time and time serialization/deserializatiom.

If I remember correctly, the Kotlin team is working on an official multiplatform solution. In the meam time, have a look at kclock!

Sorry for miss understanding. Question is: how to convert 2020-01-16T11:33:34.553Z to unix milliseconds in kotlin multiplatform?
As far as I understand, this could be done only with 3rd party libraries?

You could do it by hand but why when there is a library?
If you plan doing it by hand I assure you that representing time with all its possible string representations it’s not an easy task.

Basicly I do this conversion when I deserialize my data json (5mb file). In this deserialization I have date that is presented as string, and I would like to get it as unix timestamp. I have my @Serializer class that do the magic (currently slow, because I use some cinterop for iOS - not the best solution). I have quite big data set, so performance meters. Thats why I would like to do this with Kotlin std lib (assuming, that this is most fastest solution) instead of 3rd party lib.
Maybe also kclock would work fine, as you mentioned.