This commit is contained in:
2024-02-20 16:05:54 +08:00
parent fd51d1a357
commit 055a55cda1
7 changed files with 60 additions and 47 deletions

View File

@@ -1,9 +1,9 @@
package com.jsowell.common.util;
import com.google.common.primitives.Bytes;
import com.jsowell.common.constant.Constants;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.util.Date;
@@ -563,6 +563,9 @@ public class BytesUtil {
* @Description 16进制字符串转字节数组
*/
public static byte[] hexString2Bytes(String src) {
if (src.startsWith(Constants.HEX_PREFIX)) {
src = StringUtils.replace(src, Constants.HEX_PREFIX, "");
}
int l = src.length() / 2;
byte[] ret = new byte[l];
for (int i = 0; i < l; i++) {
@@ -631,12 +634,12 @@ public class BytesUtil {
* @param bigDecimal
* @return
*/
public static byte[] bigDecimal2Bcd(BigDecimal bigDecimal) {
int i = Float.floatToIntBits(bigDecimal.floatValue());
String hexString = Integer.toHexString(i);
return hexString2Bytes(hexString);
}
// public static byte[] bigDecimal2Bcd(BigDecimal bigDecimal) {
// int i = Float.floatToIntBits(bigDecimal.floatValue());
// String hexString = Integer.toHexString(i);
// return hexString2Bytes(hexString);
//
// }
/**
* int 转 byte[]