Java Hex Calculate toHexString(long l)

Here you can find the source of toHexString(long l)

Description

Convert a long to it's hex representation.

License

BSD License

Parameter

Parameter Description
l The long to convert.

Return

l in hex.

Declaration

public static String toHexString(long l) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    /**//from   w  w w  .  ja va  2  s  .  com
     * Convert a long to it's hex representation. Unlike
     * {@ Long#toHexString(long)} this always returns 16 digits.
     * @param l The long to convert.
     * @return l in hex.
     */
    public static String toHexString(long l) {
        String initial;
        StringBuffer sb;

        initial = Long.toHexString(l);
        if (initial.length() == 16)
            return initial;
        sb = new StringBuffer(16);
        sb.append(initial);
        while (sb.length() < 16)
            sb.insert(0, '0');
        return sb.toString();
    }
}

Related

  1. toHexString(Integer num)
  2. toHexString(long i)
  3. toHexString(long l)
  4. toHexString(long l)
  5. toHexString(long l)
  6. toHexString(long value, int digits)
  7. toHexString(long value, int digits)
  8. ToHexString(long[] data)
  9. toHexString(String data)