Converting an integer to a hexadecimal string representation in Java
inLeadingZeros I find dubious; wrong name probably
0x00_00_03_44 would be output as &quot;344&quot; whereas conventional would be a two-fold &quot;0344&quot; (or even interspaced as &quot;03 44&quot;). The reason that from left-to-right one can create a byte by two chars.
The exceptional case probably can be dealt with in front.
Error if (digit != 0) { should be if (digit != '0') { or something else is meant.
toHexChar still expects an int digit 0..10. So probably a semantic clash.
a as parameter name is unfortunate especially in English; num or n is more clear.

I am uncertain whether your code is correct by just reading it, due to the variable &amp; if.
/**
 * Converts the given integer into its textual hexadecimal representation.
 * 
 * @param num the integer to convert.
 * @return the string representing {@code num} in hexadecimal notation.
 */
public static String intToHexString(int num ) {
    if (num == 0) {
        return &quot;00&quot;;
    }
    
    StringBuilder stringBuilder = new StringBuilder(Integer.BYTES * 2);
    while (num != 0) {
        char digit = toHexChar(num &amp; 0xf);
        num &gt;&gt;&gt;= 4;
        stringBuilder.append(digit);

        digit = toHexChar(num &amp; 0xf);
        num &gt;&gt;&gt;= 4;
        stringBuilder.append(digit);
    }
    return stringBuilder.reverse().toString();
}

// Converts the integer digit to its textual hexadecimal representation:
private static char toHexChar(int digit) {
    return 0 &lt;= digit &amp;&amp; digit &lt; 10 ? 
            (char)(digit + '0') :
            (char)(digit - 10 + 'a');
}