Java Color Convert To colorToHex(int color)

Here you can find the source of colorToHex(int color)

Description

color To Hex

License

Open Source License

Declaration

public static String colorToHex(int color) 

Method Source Code

//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();
    }
}

Related

  1. colorToFloat(int color)
  2. colorToHex(int integer)
  3. colorToRGB(final int alpha, final int red, final int green, final int blue)
  4. colorToString(int color, boolean rgb)
  5. colorToStringHex(int red, int green, int blue)