|
@@ -1,11 +1,50 @@
|
|
|
package com.tokheim.sgs.v3;
|
|
|
|
|
|
import cn.hutool.core.util.HexUtil;
|
|
|
+import com.tokheim.sgs.v3.common.utils.ByteUtils;
|
|
|
+import com.tokheim.sgs.v3.common.utils.DateTimeUtils;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
|
|
|
public class HexUtilTest {
|
|
|
public static void main(String[] args) {
|
|
|
- String ipMsg = "31 30 2E 31 39 36 2E 31 39 32 2E 35 35 3A 34 39 35 31";
|
|
|
- String ip = HexUtil.decodeHexStr(ipMsg);
|
|
|
- System.out.println(ip);
|
|
|
+// String ipMsg = "31 30 2E 31 39 36 2E 31 39 32 2E 35 35 3A 34 39 35 31";
|
|
|
+// String ip = HexUtil.decodeHexStr(ipMsg);
|
|
|
+// System.out.println(ip);
|
|
|
+//
|
|
|
+// Date date1 = DateTimeUtils.parse("19710000 00:00:00");
|
|
|
+// Date date2 = DateTimeUtils.parse("20240602 22:22:22");
|
|
|
+// System.out.println("错误时间:"+date1.getTime());
|
|
|
+// System.out.println("正常时间:"+date2.getTime());
|
|
|
+// System.out.println(DateTimeUtils.getIntervalSeconds(date1,date2));
|
|
|
+
|
|
|
+
|
|
|
+ String[] balanceArr = new String[]{"00","00","00","64"};
|
|
|
+ StringBuffer balanceBuffer = new StringBuffer();
|
|
|
+ for (int i = 0; i < balanceArr.length; i++) {
|
|
|
+ // balanceBuffer.append(ByteUtils.hexToDecimal(balanceArr[i].toUpperCase()));
|
|
|
+ //balanceBuffer.append(new BigInteger(balanceArr[i], 16));
|
|
|
+ balanceBuffer.append(balanceArr[i]);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Long balanceNo = ByteUtils.hexToDecimalLong(balanceBuffer.toString());
|
|
|
+ System.out.println(balanceNo);
|
|
|
+ String balanceNo_ = String.valueOf(balanceNo);
|
|
|
+ //--
|
|
|
+ while (balanceNo_.length() < 3) {
|
|
|
+ balanceNo_ = "0"+balanceNo_;
|
|
|
+ }
|
|
|
+ System.out.println(balanceNo_);
|
|
|
+ //--
|
|
|
+ StringBuffer bal = new StringBuffer(balanceNo_);
|
|
|
+ StringBuffer balanceNoInsert = null;
|
|
|
+ if (!bal.toString().equals("0")){
|
|
|
+ balanceNoInsert = bal.insert(balanceNo_.length() - 2, ".");
|
|
|
+ }else {
|
|
|
+ balanceNoInsert = bal;
|
|
|
+ }
|
|
|
+ System.out.println(balanceNoInsert.toString());
|
|
|
+
|
|
|
}
|
|
|
}
|