Java convert hexadecimal time

I really do not know where to start, I did some research, but could not find anything. I know what I need to use a date class, but I need to do to print the date as below, but the hex value is AA, where does it get the date value from?

The image is here, since it does not allow you to download the image: http://www.facebook.com/photo.php?pid=2298915&l=e45630aead&id=1283154964

If anyone knows that I would be the biggest!

Many thanks

+3
source share
2 answers

Windows stores FileTime internally as a 100-nanoseconds number starting from 1.1.1601 UTC as a 64-bit field.

JNI Windows API FileTimeToSystemTime()? , :

http://msdn.microsoft.com/en-us/library/ms724280(VS.85).aspx

:

, 64- , ? 03A0B00A ( AA), , 03A0B008 03A0B000 03A0B0C0. , , (29.1.2011) 100 ; , , , , , 64- . , Java 1.1.1601 UTC, , , : Java 1.1.1601 UTC, ; , 64- , .

0

: AA37 D608 DFBF CB01.

, 64- 129407978957060010. , , "little-endian": 01CB BFDF 08D6 37AA.

, :

    byte[] data = new byte[] { (byte) 0xAA, (byte) 0x37, (byte) 0xD6,
            (byte) 0x08, (byte) 0xDF, (byte) 0xBF, (byte) 0xCB, (byte) 0x01 };

    // convert bytes to long time
    long val = 0;
    for(int i=7;i>=0;i--) {
        val <<= 8;
        val += 0xff & data[i];
    }

    // convert 100 nanos to milliseconds
    val /= 10000;

    // convert to time offset from 1st Jan 1601 AD
    Calendar calend = Calendar.getInstance();
    calend.set(1601,0,01,00,00,00);
    calend.set(Calendar.MILLISECOND, 0);
    val += calend.getTimeInMillis();
    calend.setTimeInMillis(val);

    // display result
    DateFormat df = DateFormat.getDateTimeInstance();
    System.out.println(df.format(calend.getTime()));
0

Source: https://habr.com/ru/post/1796371/


All Articles