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

[3292 byte] By [scaaven] at [2007-9-30 3:46:45]
# 1

if it helps any, here is a longer sequence of timestamps

0C 9B 03 35 00 BB 00 1F

0C 9B 03 35 00 BB 00 3E

0C 9B 03 35 00 BB 00 6D

0C 9B 03 35 00 BB 00 8C

0C 9B 03 35 00 BB 00 AB

0C 9B 03 35 00 BB 00 CB

0C 9B 03 35 00 BB 00 EA

0C 9B 03 35 00 BB 01 09

0C 9B 03 35 00 BB 01 28

0C 9B 03 35 00 BB 01 57

0C 9B 03 35 00 BB 01 77

0C 9B 03 35 00 BB 01 96

0C 9B 03 35 00 BB 01 B5

0C 9B 03 35 00 BB 01 D4

0C 9B 03 35 00 BB 01 F4

0C 9B 03 35 00 BB 02 22

0C 9B 03 35 00 BB 02 42

0C 9B 03 35 00 BB 02 61

0C 9B 03 35 00 BB 02 80

0C 9B 03 35 00 BB 02 9F

0C 9B 03 35 00 BB 02 BF

0C 9B 03 35 00 BB 02 DE

0C 9B 03 35 00 BB 03 0D

0C 9B 03 35 00 BB 03 2C

0C 9B 03 35 00 BB 03 4B

0C 9B 03 35 00 BB 03 6B

0C 9B 03 35 00 BB 03 8A

0C 9B 03 35 00 BB 03 A9

0C 9B 03 35 00 BB 03 C8

0C 9C 03 35 00 BB 00 00

0C 9C 03 35 00 BB 00 2E

0C 9C 03 35 00 BB 01 A5

0C 9C 03 35 00 BB 01 C5

0C 9C 03 35 00 BB 01 E4

0C 9C 03 35 00 BB 02 03

0C 9C 03 35 00 BB 02 22

0C 9C 03 35 00 BB 02 42

0C 9C 03 35 00 BB 02 61

0C 9C 03 35 00 BB 02 90

0C 9C 03 35 00 BB 02 AF

0C 9C 03 35 00 BB 02 CE

0C 9C 03 35 00 BB 02 EE

0C 9C 03 35 00 BB 03 0D

0C 9C 03 35 00 BB 03 2C

0C 9C 03 35 00 BB 03 4B

0C 9C 03 35 00 BB 03 6B

0C 9C 03 35 00 BB 03 8A

0C 9C 03 35 00 BB 03 B9

0C 9C 03 35 00 BB 03 D8

0C 9D 03 35 00 BB 00 0F

0C 9D 03 35 00 BB 00 2E

0C 9D 03 35 00 BB 00 4E

0C 9D 03 35 00 BB 00 6D

0C 9D 03 35 00 BB 00 9C

0C 9D 03 35 00 BB 00 BB

0C 9D 03 35 00 BB 00 DA

0C 9D 03 35 00 BB 00 FA

0C 9D 03 35 00 BB 01 19

0C 9D 03 35 00 BB 01 48

0C 9D 03 35 00 BB 01 67

0C 9D 03 35 00 BB 01 96

0C 9D 03 35 00 BB 01 B5

0C 9D 03 35 00 BB 01 E4

0C 9D 03 35 00 BB 02 03

0C 9D 03 35 00 BB 02 22

0C 9D 03 35 00 BB 02 51

0C 9D 03 35 00 BB 02 71

0C 9D 03 35 00 BB 02 9F

0C 9D 03 35 00 BB 02 BF

0C 9D 03 35 00 BB 02 EE

0C 9D 03 35 00 BB 03 0D

0C 9D 03 35 00 BB 03 2C

0C 9D 03 35 00 BB 03 5B

0C 9D 03 35 00 BB 03 7A

0C 9D 03 35 00 BB 03 A9

0C 9D 03 35 00 BB 03 C8

0C 9E 03 35 00 BB 00 00

0C 9E 03 35 00 BB 00 2E

0C 9E 03 35 00 BB 01 86

0C 9E 03 35 00 BB 01 B5

0C 9E 03 35 00 BB 01 D4

0C 9E 03 35 00 BB 02 03

0C 9E 03 35 00 BB 02 22

0C 9E 03 35 00 BB 02 51

0C 9E 03 35 00 BB 02 71

0C 9E 03 35 00 BB 02 9F

0C 9E 03 35 00 BB 02 BF

0C 9E 03 35 00 BB 02 EE

0C 9E 03 35 00 BB 03 0D

0C 9E 03 35 00 BB 03 3C

0C 9E 03 35 00 BB 03 5B

0C 9E 03 35 00 BB 03 7A

0C 9E 03 35 00 BB 03 A9

0C 9E 03 35 00 BB 03 C8

0C 9F 03 35 00 BB 00 0F

0C 9F 03 35 00 BB 00 3E

0C 9F 03 35 00 BB 00 5D

0C 9F 03 35 00 BB 00 8C

0C 9F 03 35 00 BB 00 AB

0C 9F 03 35 00 BB 00 DA

0C 9F 03 35 00 BB 00 FA

0C 9F 03 35 00 BB 01 28

scaaven at 2007-6-29 14:59:48 > top of Java-index,Archived Forums,Java Programming...
# 2

Java stores binary values internally and in files MSB (Most Significant Byte) first, i.e. high order part first. This is referred to as big-endian byte sex or sometimes network order. What do you do if your data files are in little-endian format as would be the case for most Windows-95 binary files?

read here... http://mindprod.com/jgloss/endian.html

good luck!

760613 at 2007-6-29 14:59:48 > top of Java-index,Archived Forums,Java Programming...