Exemplo n.º 1
0
  /**
   * Converts a long value to a hexadecimal String of length 16. Includes leading zeros if
   * necessary.
   *
   * @param value The long value to be converted.
   * @return The hexadecimal string representation of the long value.
   */
  public static String toFullHexString(long value) {
    long currentValue = value;
    StringBuffer stringBuffer = new StringBuffer(16);
    for (int j = 0; j < 16; j++) {
      int currentDigit = (int) currentValue & 0xf;
      stringBuffer.append(HEX_DIGITS[currentDigit]);
      currentValue >>>= 4;
    }

    return stringBuffer.reverse().toString();
  }
Exemplo n.º 2
0
  /**
   * Converts a int value to a hexadecimal String of length 8. Includes leading zeros if necessary.
   *
   * @param value The int value to be converted.
   * @return The hexadecimal string representation of the int value.
   */
  public static String toFullHexString(int value) {
    int currentValue = value;
    StringBuffer stringBuffer = new StringBuffer(8);
    for (int i = 0; i < 8; i++) {
      int currentDigit = currentValue & 0xf;
      stringBuffer.append(HEX_DIGITS[currentDigit]);
      currentValue >>>= 4;
    }

    return stringBuffer.reverse().toString();
  }