Java Integer to Hex intToHexWithPadding(Integer input, Integer max_size)

Here you can find the source of intToHexWithPadding(Integer input, Integer max_size)

Description

int To Hex With Padding

License

Open Source License

Declaration

public static String intToHexWithPadding(Integer input, Integer max_size) 

Method Source Code

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

public class Main {
    public static String intToHexWithPadding(Integer input, Integer max_size) {
        if (max_size <= 8) {
            return String.format("%02x", input);
        } else if (max_size <= 16) {
            return String.format("%04x", input);
        } else {/*from  ww w.ja v a 2  s  . com*/
            return String.format("%08x", input);
        }
    }
}

Related

  1. intToHexString(int num)
  2. intToHexString(int number)
  3. intToHexString(int val, int width)
  4. intToHexString(int value)
  5. intToHexString(int value, int digits)