Color to Hex String - Java 2D Graphics

Java examples for 2D Graphics:Color String

Description

Color to Hex String

Demo Code


//package com.java2s;
import java.awt.Color;

public class Main {
    public static String toHexString(final Color color) {
        final int rgb = color.getRGB();
        final String hex = String.format("#%06X", (0xFFFFFF & rgb));

        return hex;
    }//  ww  w  . j av a2s .  c o m
}

Related Tutorials