1078-设置圆形区域...

This commit is contained in:
648540858
2024-05-03 18:58:49 +08:00
parent 4011e54dd8
commit 5dd49b3d44
8 changed files with 222 additions and 6 deletions

View File

@@ -1,5 +1,12 @@
package com.genersoft.iot.vmp.jt1078.util;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.time.Instant;
import java.util.Calendar;
import java.util.Date;
/**
* BCD码转换
*/
@@ -19,4 +26,26 @@ public class BCDUtil {
}
return stringBuffer.toString();
}
/**
* 时间使用按照YY-MM-DD-hh-mm-ss转换为byte数据
*/
public static ByteBuf transform(long time) {
ByteBuf byteBuf = Unpooled.buffer();
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1 ;
int day = calendar.get(Calendar.DAY_OF_MONTH);
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
byteBuf.writeByte(year);
byteBuf.writeByte(month);
byteBuf.writeByte(day);
byteBuf.writeByte(hour);
byteBuf.writeByte(minute);
byteBuf.writeByte(second);
return byteBuf;
}
}