code: public static String decToHex(int dec, int minDigits) {
          String ret = Integer.toHexString(dec);
          while (ret.length() < minDigits) {
              ret = '0' + ret;
          }
          return ret;
      }
docs: Converts an integer to hexadecimal form with at least the minimum of digits specified (by adding leading zeros).
  
  @param dec The integer to convert
  @param minDigits The minimum of digits in the hexadecimal form
  @return The integer in hexadecimal form