help convert windows FILETIME from file to a java date
I am having a terrible time trying to hack this one. I have a file format that places a windows timestamp in the form of FILETIME on each frame of data. Windows encodes stuff in little endian (i think), and everything I've tried has failed to grab this 8 bytes of data and convert it to nanoseconds...
the FILETIME is stored as 8 bytes, representing the # of nanoseconds since year 1601 i think. I dont know if windows stores this as[byte7, byte8] [byte5, byte6] [byte3, byte4] [byte1, byte2]or just in complete reverse order. the thing pissing me off is the very last 2 bytes change like a sequence, and the 2nd byte from the front changes with it. everything else remains stationary and it makes no sense. Here is a sequence of the timestamps in hex:
0C A5 03 35 00 BB 00 EA
0C A5 03 35 00 BB 01 19
0C A5 03 35 00 BB 01 38
0C A5 03 35 00 BB 01 57
0C A5 03 35 00 BB 01 86
0C A5 03 35 00 BB 01 A5
0C A5 03 35 00 BB 01 D4
0C A5 03 35 00 BB 01 F4
0C A5 03 35 00 BB 02 13
0C A5 03 35 00 BB 02 42
0C A5 03 35 00 BB 02 61
0C A5 03 35 00 BB 02 90
0C A5 03 35 00 BB 02 AF
0C A5 03 35 00 BB 02 DE
0C A5 03 35 00 BB 02 FD
0C A5 03 35 00 BB 03 1C
0C A5 03 35 00 BB 03 4B
0C A5 03 35 00 BB 03 6B
0C A5 03 35 00 BB 03 99
0C A5 03 35 00 BB 03 B9
0C A6 03 35 00 BB 00 00
0C A6 03 35 00 BB 00 1F
these bytes are stored by windows, so how can i decode this into a legible java number? Thanks!
Here's some code i've tried to use to solve my prob:
byte t1 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(0);
byte t2 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(1);
byte t3 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(2);
byte t4 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(3);
byte t5 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(4);
byte t6 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(5);
byte t7 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(6);
byte t8 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).get(7);
System.out.println(t1 +", " + t2 +", " + t3 +", " + t4 +", " + t5 +", " + t6 +", " + t7 +", " + t8);
short t1 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).getShort();
short t2 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).getShort(2);
short t3 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).getShort(4);
short t4 = ByteBuffer.wrap(timeArray).order(ByteOrder.BIG_ENDIAN).getShort(6);
-Adam

