public static void main(String[] args) {
String s = "1318149202000";
Long longNumber = Long.parseLong(s);
byte[] b =longToBytes(longNumber);
for (byte c : b) {
System.out.print(c+"\t");
}
}
public static byte[] longToBytes(long l) {
byte[] b = new byte[8];
b[0] = (byte) (l >>> 56);
b[1] = (byte) (l >>> 48);
b[2] = (byte) (l >>> 40);
b[3] = (byte) (l >>> 32);
b[4] = (byte) (l >>> 24);
b[5] = (byte) (l >>> 16);
b[6] = (byte) (l >>> 8);
b[7] = (byte) (l);
return b;
}
你是要这样吗?