java 0A03170F3217解析成16进制的时间 :2010年3月23日15时50分23秒
首先,将字符串"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());
原文地址: http://www.cveoy.top/t/topic/iVUn 著作权归作者所有。请勿转载和采集!