-3

I have a requirement to convert color into Hexadecimal code in Java. I have color available in Java class like Red, Green, Anthracite . I need to convert it into Hex code and return back to JSP.

Techie
  • 45
  • 1
  • 1
  • 7

1 Answers1

0

There are different way for your question You can use your_color.getRGB() for get rgb and use Integer.toHexString(your_color.getRGB()) return string

String hex = "#" + Integer.toHexString(your_color.getRGB()).substring(2);

substring for don't select alpha

Yashar Panahi
  • 2,816
  • 1
  • 16
  • 22