I am trying to convert int to binary and i am doing below code.
public static String intToBinary16Bit(String strInt) {
String bin = Integer.toBinaryString(strInt);
return String.format("%016d", Integer.parseInt(bin));
}
So, if i am giving strInt = 0211 than it is working fine and giving the output
0000001000010001.
But, if i am giving strInt = 4527 than it is throwing NumberFormateException.
How can I resolved this issue ?