Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String getHexForColor(int c) { return "#" + Integer.toHexString((c & 0xffffff) | 0x1000000).substring(1); } }