Java Hex Calculate toHexString(long l)

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

Description

J2ME/J9 compatibility instead of Long.toHexString Copied from bluecove: http://www.bluecove.org/bluecove/apidocs/com/intel/bluetooth/Utils.html

License

Open Source License

Declaration

public static String toHexString(long l) 

Method Source Code

//package com.java2s;
/*/*w  w  w . java  2  s  .c om*/
 * Copyright (C) 2008 onwards University of Deusto
 * 
 * All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.
 * 
 * This software consists of contributions made by many individuals, 
 * listed below:
 *
 * Author: Aitor G?mez Goiri <aitor.gomez@deusto.es>
 */

public class Main {
    /**
     * J2ME/J9 compatibility instead of Long.toHexString
     * 
     * Copied from bluecove:
     *    http://www.bluecove.org/bluecove/apidocs/com/intel/bluetooth/Utils.html
     */
    public static String toHexString(long l) {
        StringBuffer buf = new StringBuffer();
        String lo = Integer.toHexString((int) l);
        if (l > 0xffffffffl) {
            String hi = Integer.toHexString((int) (l >> 32));
            buf.append(hi);
            for (int i = lo.length(); i < 8; i++) {
                buf.append('0');
            }
        }
        buf.append(lo);
        return buf.toString();
    }
}

Related

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