Here you can find the source of colorToHex(int color)
public static String colorToHex(int color)
//package com.java2s; //License from project: Open Source License public class Main { private static final char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static String colorToHex(int color) { StringBuilder hexBuilder = new StringBuilder(6); hexBuilder.setLength(6);// w w w.ja v a2 s .c o m for (int i = 5; i >= 0; i--) { int j = color & 0x0F; hexBuilder.setCharAt(i, hexDigits[j]); color >>= 4; } return hexBuilder.toString(); } }