Java Integer to Hex integerToHex(final Object value, final int desimals)

Here you can find the source of integerToHex(final Object value, final int desimals)

Description

integer To Hex

License

Open Source License

Declaration

public static String integerToHex(final Object value, final int desimals) 

Method Source Code

//package com.java2s;
// and/or modify it under the terms of the GNU General Public License 

public class Main {
    private static String zeroes = "00000000000000000000000000000000";

    public static String integerToHex(final Object value, final int desimals) {
        String str = Long.toString(((Number) value).longValue(), 16).toUpperCase();
        if (desimals == 0 || str.length() == zeroes.length()) {
            return str;
        }//from  www .  j a  v  a 2 s  . c  o  m
        return zeroes.substring(0, desimals - str.length()) + str;
    }
}

Related

  1. int2HexString(final int i)
  2. int2HexString(int n)
  3. int2hexString(int x)
  4. int2HexString(StringBuilder buf, int value)
  5. int2HexZeroPad(int i)
  6. integerToHex(final Object value, final int desimals)
  7. integerToHex(int val)
  8. integerToHexShort(int value)
  9. integerToHexString(final int aValue, final int aFieldWidth)