Java Color Encode encodeColorForCss(Color color)

Here you can find the source of encodeColorForCss(Color color)

Description

encode Color For Css

License

Open Source License

Declaration

public static String encodeColorForCss(Color color) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;

public class Main {
    public static String encodeColorForCss(Color color) {
        if (null == color) {
            return "#000000";
        }/*from  www . j  a  va 2  s.co  m*/

        return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()).toUpperCase();
    }
}

Related

  1. encode(java.awt.Color c)
  2. encodeColor(Color color)
  3. encodeColor(Color color)
  4. encodeColor(Color color)
  5. encodeColor(int r, int g, int b)
  6. encodeRGB(Color color)
  7. encodeRGBHexString(Color color, boolean withAlpha)
  8. encodeRGBIntString(Color color, boolean withAlpha)