I am trying to get the Little Endian format value in Hex(in Java) for my code but getting fffff in the first digit and not getting the value similar to what this site returns: https://www.rapidtables.com/convert/number/decimal-to-hex.html
Here is the code:
private static void convertToHex() {
String hextestValue = Integer.toHexString(1234);
int value = Integer.parseInt(hextestValue, 16);
ByteBuffer bb = ByteBuffer.allocate(4);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(value);
System.out.print("x = ");
for (byte b : bb.array()) {
System.out.printf("%2s", Integer.toHexString(b) + " ");
}
}
Not sure what needs to be done to return the result in similar format.
e.g. for input 1234 I need the output: D2 04