Java Integer to Hex intToHex(int val)

Here you can find the source of intToHex(int val)

Description

Converts an int to a hex String.

License

Open Source License

Declaration

public static String intToHex(int val) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*  ww  w  .  j  av a2  s  .  co  m*/
     * Converts an int to a hex String.
     */
    public static String intToHex(int val) {
        String hex = Integer.toHexString(val);

        if (hex.length() >= 8) {
            return hex.substring(hex.length() - 8);
        }

        return String.format("%8s", hex).replace(' ', '0');
    }
}

Related

  1. intToHex(int i)
  2. intToHex(int i)
  3. IntToHex(int i, int length)
  4. intToHex(int id)
  5. intToHex(int num)
  6. intToHex(int val, char delim)
  7. intToHex(int val, StringBuffer sb)
  8. intTohex2(int value)
  9. intToHex8(int value)