首先,将字符串'0A03170F3217' 转换为字节数组:

byte[] bytes = DatatypeConverter.parseHexBinary('0A03170F3217');

然后,将字节数组转换为对应的时间格式:

Calendar calendar = Calendar.getInstance();
calendar.set(bytes[0] + 2000, bytes[1] - 1, bytes[2], bytes[3], bytes[4], bytes[5]);

最后,获取时间的字符串表示:

SimpleDateFormat dateFormat = new SimpleDateFormat('yyyy年MM月dd日HH时mm分ss秒');
String time = dateFormat.format(calendar.getTime());

原文地址: https://www.cveoy.top/t/topic/qBT2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录