How can a 4-byte long integer be transformed into a long number for java?

for example: 7D 17 4F 5B
this is a time byte.

probably 1531881242100 to get the current time cut. However, when I decode it, the numbers are always wrong.
this is the data read from modbus.
anyway, high and low positions, switching back and forth, is just the wrong time. How to solve it? The
above gets a long value, and then converts it into time format using SimpleDateFormat.

Mar.28,2021

just convert hex to long, and the code will not be posted. Your 4-byte is 32-bit, while long is 64-bit, so you should be missing 4 bytes.


after repeated attempts, it cannot be parsed.

    @Test
    public void test9(){
        Date date=new Date(1531910014000L);
        System.out.println(date);
    }
    
    @Test
    public void test10(){
        String[] strs=new String[]{"7D","17","4F","5B"};
        long lng=1;
        for(int i=0;i<strs.length;iPP){
            lng+=Integer.valueOf(strs[i], 16) * Math.pow(256, Math.abs(i));
        }
        lng*=1000;
        System.out.println(lng);
    }

test10 output: 1531910014000
test9 output: Wed Jul 18 18:33:34 CST 2018

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45a07-44b50.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45a07-44b50.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?