parseHexOrNull
Parses a uuid from the hexadecimal string representation as described in Uuid.toHexString, returning null if a string has a different format.
This function is case-insensitive, and for a valid hexString, the following property holds:
val uuid = Uuid.parseHexOrNull(hexString)!!
assertEquals(uuid.toHexString(), hexString.lowercase())Content copied to clipboard
Since Kotlin
2.3Return
A uuid represented by the specified hexadecimal string, or null, if the string does not conform the format.
Parameters
hexString
A 32-character hexadecimal string representing the uuid, without hyphens.
See also
Samples
import kotlin.test.*
import kotlin.time.Instant
import kotlin.uuid.*
fun main() {
//sampleStart
val uuid = Uuid.parseHexOrNull("550E8400e29b41d4A716446655440000") // case insensitive
println(uuid) // 550e8400-e29b-41d4-a716-446655440000
assertNull(Uuid.parseHexOrNull("~550E8400e29b41d4A716446655440000~"))
//sampleEnd
}