You're receiving ArrayIndexOutOfBoundException
probably, so I think the hex value might have zero in its most significant nibble. Try to find out those values(x
) and check whether (x >>> 12) == 0
or (x & 0xf000) == 0
. If this returns true, you can pad your string with necessary number of 0
s from the left.
One possible way: String.format("%04d", crrc)