Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { final public static String encodeLongToHex(final int color) { StringBuilder builder = new StringBuilder(); String colorStr = Long.toHexString(color); int i = 8 - colorStr.length(); while (i != 0) { builder.append("0"); i--; } builder.append(Long.toHexString(color)); return builder.toString(); } }