rgb to hex java code example
Example 1: rgb to hex java
int r = 20;
int g = 99;
int b = 155;
String hex = String.format("#%02X%02X%02X", r, g, b);
System.out.println(hex);
//Output #14639B
Example 2: java hex to rgb
Color.decode("#FFCCEE");
int r = 20;
int g = 99;
int b = 155;
String hex = String.format("#%02X%02X%02X", r, g, b);
System.out.println(hex);
//Output #14639B
Color.decode("#FFCCEE");