There is kotlinx-datetime - the multiplatform clone of Java Date/Time API.
It there any plans to create multiplatform analog of java.util.UUID?
I’m currently using a 3rd party library for that:
Thank you!
Alternative: GitHub - cy6erGn0m/kotlinx-uuid: kotlinx-uuid is a multiplatform (MPP) Kotlin library introducing support for UUID.
or my fork GitHub - hfhbd/kotlinx-uuid: kotlinx-uuid is a multiplatform (MPP) Kotlin library introducing support for UUID.
Hey, @brunojcm Can you show me an implementation of it I have a data class named Children and in it I have a parameter id and I want to implement it to it I have some difficulties implementing it since there is no samples in that repo so can you help me?
Can you post some code here so I can understand what you’re doing?
Data class Children (
val id : Long, // = Uuid
val name : String,
val age : Int
)
I am trying to generate an Id but i can’t figure out how to with this library
@brunojcm
its ok i got it, i used uuid4().toString.toLong
This should not work, a String representing a UUID is not convertible to a Long. Even in its binary form, a UUID needs 2 Longs worth of bits to be represented in memory.
Just FYI there’s a UUID type in the standard library as of Kotlin 2.0.20: