且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从Millis转换为十六进制字符串

更新时间:2022-06-04 04:32:40

尝试一下:

 String major1 = String.format("%02X", (millis >> 32) & 0xff);
 String major2 = String.format("%02X", (millis >> 16) & 0xff);
 String minor1 = String.format("%02X", (millis >> 8) & 0xff);
 String minor2 = String.format("%02X", millis & 0xff);

上面的代码访问时间戳中的每个字节,并将其分配给适当的字段,然后对其进行格式化作为两个字符(一个字节)的十六进制数字。您希望脚本使用两个字符的十六进制数字。

The code above accesses each byte out of the timestamp and assigns it to the proper field, then formats it as a two character (one byte) hex number. A two character hex number is what you want for the script.