您需要 2long秒来存储UUID.
UUID myuuid = UUID.randomUUID();
long highbits = myuuid.getMostSignificantBits();
long lowbits = myuuid.getLeastSignificantBits();
System.out.println("My UUID is: " + highbits + " " + lowbits);
Run Code Online (Sandbox Code Playgroud)
getMostSigBits()和getLeastSigBits()获取长值。byte[]。BigInteger对象。BigInteger的toString()将是一个UUID可以潜在为负。您可以通过将-标志替换为1或其他类似方法来解决此问题。我还没有测试过,但是#gimmetehcodez
long hi = id.getMostSignificantBits();
long lo = id.getLeastSignificantBits();
byte[] bytes = ByteBuffer.allocate(16).putLong(hi).putLong(lo).array();
BigInteger big = new BigInteger(bytes);
String numericUuid = big.toString().replace('-','1'); // just in case
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19791 次 |
| 最近记录: |