rgb to hex java

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
Source

Also in Java: