com.github.lsqlebai.utils.UUIDUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-common Show documentation
Show all versions of server-common Show documentation
An kotlin server common jar
package com.github.lsqlebai.utils
import java.math.BigInteger
import java.util.*
object UUIDUtils {
fun uuid(): String {
val uuid = UUID.randomUUID()
val str = uuid.toString()
// 去掉"-"符号
val temp: String
temp = str.replace("-".toRegex(), "")
return temp
}
fun sn(): String {
val uuid = uuid()
val longSn = BigInteger(uuid, 16).toString()
return longSn.substring(0, 12)
}
fun sn(num: Int): String {
val uuid = uuid()
val longSn = BigInteger(uuid, 16).toString()
return longSn.substring(0, num)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy