Java Hex Calculate toHexString(int decimal, int stringLength)

Here you can find the source of toHexString(int decimal, int stringLength)

Description

Converts a decimal value to a hexadecimal string represention of the specified length.

License

Open Source License

Parameter

Parameter Description
decimal A decimal value.
stringLength The length of the resulting string.

Declaration

private static String toHexString(int decimal, int stringLength) 

Method Source Code

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

public class Main {
    /**//  ww w  .j  av a2s .com
     * Converts a decimal value to a hexadecimal string represention of the
     * specified length. For unicode escaping.
     *
     * @param decimal
     *            A decimal value.
     * @param stringLength
     *            The length of the resulting string.
     **/
    private static String toHexString(int decimal, int stringLength) {
        return String.format("%0" + stringLength + "X", decimal);
    }
}

Related

  1. toHexString(final int value)
  2. toHexString(final long num, final char paddingChar, int min, int max)
  3. toHexString(int b)
  4. toHexString(int b)
  5. toHexString(int bits, int value)
  6. toHexString(int decimal, int stringLength)
  7. toHexString(int i)
  8. toHexString(int i)
  9. toHexString(int i)