/**
* long转换为小端byte[](高位放在高地址中)
* @param lValue
* @return
*/
public static byte[] Long2Bytes_LE(long lValue){
byte[] rst = new byte[4];
// 先写最后一个字节
rst[0] = (byte)(lValue & 0xFF);
// 倒数第二个字节
rst[1] = (byte)((lValue & 0xFF00) >> 8 );
// 倒数第三个字节
rst[2] = (byte)((lValue & 0xFF0000) >> 16 );
// 第一个字节
rst[3] = (byte)((lValue & 0xFF000000) >> 24 );
return rst;
}
public static String convertM1CardNumber(String str)
{
String result = "";
long value = (long)(Double.parseDouble(str));
byte[] arrayResult = Long2Bytes_LE(value);
for(int i=0; i<4; i++) {
result += String.format("%02X", arrayResult[i]);
}
return result;
}
public static void main(String[] args)
{
String str = convertM1CardNumber("0002062710");
//String str = convertM1CardNumber("22855993");
System.out.println("CardNumber: " + str);
}