Try this.
int left = 0x0FA3BC04; //262388740; // 1st 4 bytes
int right = 0x28000CF9; //671091961; // Rest of 4 bytes
long destinationID = ((right & 0xFFL) << 56) | ((right & 0xFF00L) << 40) | ((right & 0xFF0000L) << 24) | ((right & 0xFF000000L) << 8) | ((left & 0xFFL) << 24) | ((left & 0xFF00L) << 8) | ((left >> 8) & 0xFF00L) | ((left >> 24) & 0xFFL);
System.out.printf("left: %08X%n", left); //left: 0FA3BC04
System.out.printf("right: %08X%n", right); //right: 28000CF9
System.out.println("Expected - f9 0c 00 28 04 bc a3 0f");
System.out.println(Long.toHexString(destinationID)); //f90c002804bca30f
Explanation.
Let change the value of left and right for clarity.
int left = 0x01234567;
int right = 0x89ABCDEF;
((right & 0xFFL) << 56)
= filter 8 rightmost bits or 1 byte (0x00000000000000_EF
), then pad with 56 bits or 7 bytes of zeros to its right (0xEF_00000000000000
).
((right & 0xFF00L) << 40)
= filter 16 rightmost bits or 2 bytes (0x000000000000_CD00
), then pad with 40 bits or 5 bytes of zeros to its right (0x00CD00_0000000000
).
((right & 0xFF0000L) << 24)
= filter 24 rightmost bits or 3 bytes (0x0000000000_AB0000
), then pad with 24 bits or 3 bytes of zeros to its right (0x0000AB0000_000000
).
((right & 0xFF000000L) << 8)
= filter 32 rightmost bits or 4 bytes (0x00000000_89000000
), then pad with 8 bits or 1 byte of zeros to its right (0x00000089000000_00
).
((left & 0xFFL) << 24)
= filter 8 rightmost bits or 1 byte (0x00000000000000_67
), then pad with 24 bits or 3 bytes of zeros to its right (0x0000000067_000000
).
((left & 0xFF00L) << 8)
= filter 16 rightmost bits or 2 bytes (0x000000000000_4500
), then pad with 8 bits or 1 byte of zeros to its right (0x00000000004500_00
).
((left >> 8) & 0xFF00L)
= remove 8 rightmost bits or 1 byte from 0x01234567
to 0x00012345
, then get 16 rightmost bits or 2 bytes (0x000000000000_2300
).
((left >> 24) & 0xFFL)
= remove 24 rightmost bits or 3 byte from 0x01234567
to 0x00000001
, then get 8 rightmost bits or 1 byte (0x00000000000000_01
).
Bitwise OR (|
) between value is to merge them all into one.
0xEF00000000000000
0x00CD000000000000
0x0000AB0000000000
0x0000008900000000
0x0000000067000000
0x0000000000450000
0x0000000000002300
0x0000000000000001
------------------------
0xEFCDAB8967452301
------------------------