public static String toColorString(Color pColor) {
        // Not a color...
        if (pColor == null) {
            return null;
        }

        StringBuilder str = new StringBuilder(Integer.toHexString(pColor.getRGB()));

        // Make sure string is 8 chars
        for (int i = str.length(); i < 8; i++) {
            str.insert(0, '0');
        }

        // All opaque is default
        if (str.charAt(0) == 'f' && str.charAt(1) == 'f') {
            str.delete(0, 2);
        }

        // Prepend hash
        return str.insert(0, '#').toString();
    }
public static String toColorString ( Color pColor ) { if ( pColor == null ) { return null ; } StringBuilder str = new StringBuilder ( Integer . toHexString ( pColor . getRGB ( ) ) ) ; for ( int i = str . length ( ) ; i < 8 ; i ++ ) { str . insert ( 0 , '0' ) ; } if ( str . charAt ( 0 ) == 'f' && str . charAt ( 1 ) == 'f' ) { str . delete ( 0 , 2 ) ; } return str . insert ( 0 , '#' ) . toString ( ) ; }
Creates a HTML/CSS String representation of the given color.
The HTML/CSS color format is defined as:
<UL>
<LI>{@code #RRGGBB}, where RR, GG and BB means two digit
hexadecimal for red, green and blue values respectively.</LI>
<LI>{@code #AARRGGBB}, as above, with AA as alpha component.</LI>
</UL>
<p/>
Examlples: {@code toColorString(Color.red) == "#ff0000"},
{@code toColorString(new Color(0xcc, 0xcc, 0xcc)) == "#cccccc"}.

@param pColor the color
@return A String representation of the color on HTML/CSS form
@todo Consider moving to ImageUtil?