parse
Parses a uuid from one of the supported string representations.
This function supports parsing the standard hex-and-dash and the hexadecimal string representations. For details about the hex-and-dash format, refer to toHexDashString. If parsing only the hex-and-dash format is desired, use parseHexDash instead. For details about the hexadecimal format, refer to toHexString. If parsing only the hexadecimal format is desired, use parseHex instead.
Note that this function is case-insensitive, meaning both lowercase and uppercase hexadecimal digits are considered valid. Additionally, support for more uuid formats may be introduced in the future. Therefore, users should not rely on the rejection of formats not currently supported.
Since Kotlin
2.0Return
A uuid equivalent to the specified uuid string.
Parameters
A string in one of the supported uuid formats.
See also
Throws
If the uuidString is not in a supported uuid format.
Samples
import kotlin.test.*
import kotlin.uuid.*
fun main() {
//sampleStart
// Parsing is case-insensitive
val uuid1 = Uuid.parse("550E8400-e29b-41d4-A716-446655440000") // hex-and-dash
val uuid2 = Uuid.parse("550e8400E29b41D4a716446655440000") // hexadecimal
println("uuid1 == uuid2 is ${uuid1 == uuid2}") // true
println(uuid1) // 550e8400-e29b-41d4-a716-446655440000
println(uuid2) // 550e8400-e29b-41d4-a716-446655440000
//sampleEnd
}