mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
替换convertToLong方法为ByteUtil的toLong方法
This commit is contained in:
parent
06c6db14f0
commit
dc9a2092ff
@ -17,9 +17,11 @@
|
||||
package org.dromara.hutool.core.data.id;
|
||||
|
||||
import org.dromara.hutool.core.codec.Number128;
|
||||
import org.dromara.hutool.core.util.ByteUtil;
|
||||
import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
@ -208,7 +210,8 @@ public class UUID implements java.io.Serializable, Comparable<UUID> {
|
||||
randomBytes[8] &= 0x3f; /* clear variant */
|
||||
randomBytes[8] |= 0x80; /* set to IETF variant */
|
||||
|
||||
return new UUID(convertToLong(randomBytes, 0), convertToLong(randomBytes, 8));
|
||||
return new UUID(ByteUtil.toLong(randomBytes, 0, ByteOrder.BIG_ENDIAN),
|
||||
ByteUtil.toLong(randomBytes, 8, ByteOrder.BIG_ENDIAN));
|
||||
}
|
||||
|
||||
private static long[] getV7Time() {
|
||||
@ -230,13 +233,6 @@ public class UUID implements java.io.Serializable, Comparable<UUID> {
|
||||
}
|
||||
}
|
||||
|
||||
private static long convertToLong(byte[] bytes, int start) {
|
||||
long result = 0;
|
||||
for (int i = start; i < start + 8; i++) {
|
||||
result = (result << 8) | (bytes[i] & 0xFF);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 {@link #toString()} 方法中描述的字符串标准表示形式创建{@code UUID}。
|
||||
|
Loading…
x
Reference in New Issue
Block a user