Here you can find the source of longtoHexString(long wert, int bits)
public static String longtoHexString(long wert, int bits)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 EmbSysRegView//from ww w . java2s .c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * ravenclaw78 - initial API and implementation *******************************************************************************/ public class Main { public static String longtoHexString(long wert, int bits) { int hexdigits = bits / 4; if (bits % 4 != 0) hexdigits++; StringBuilder hex = new StringBuilder(); hex.append("0x"); String x = Long.toHexString(wert); int missingLen = hexdigits - x.length(); for (int i = 0; i < missingLen; i++) hex.append('0'); hex.append(x.toUpperCase()); return hex.toString(); } }