To left pad a number with zeros if there are fewer than two digits we use this:
String.format("%02d", aBlkNo);
However, aBlkNo
should be a hex string not a decimal. What can I do to render a two digit hex string from a byte
with zeros padded when necessary?
Use "x" or "X" instead of "d":
String.format("%02x", aBlkNo);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With