ColorConverter { public static String rgb2Hex(Color color) { return (String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue())).toUpperCase(); } private  ColorConverter(); static Color offsetHsbColor(Color color, float offsetHue, float offsetSaturation, float offsetBrightness); static Float getBrightness(Color color); static Float getSaturation(Color color); static Float getHue(Color color); static Color offsetRgbColor(Color bgColor, int offsetRed, int offsetGreen, int offsetBlue); static String formatColorStr(String colorStr); static Color colorFromStr(String colorStr); static Color colorFromColorName(String colorStr); static Color colorFromRgbStr(String colorStr); static Color hex2Rgb(String colorStr); static String hex2Rgb(Color color); static String rgb2Hex(Color color); static String rgb2Hsl(Color color);  }
@Test public void testRgb2hexBlack() { System.out.println("Rgb2hexBlack"); Color color = Color.BLACK; String expResult = "#000000"; String result = ColorConverter.rgb2Hex(color); assertEquals(expResult, result); }
@Test public void testRgb2hexWhite() { System.out.println("Rgb2hexWhite"); Color color = Color.WHITE; String expResult = "#FFFFFF"; String result = ColorConverter.rgb2Hex(color); assertEquals(expResult, result); }
@Test public void testRgb2hexPink() { System.out.println("Rgb2hexPink"); Color color = Color.PINK; String expResult = "#FFAFAF"; String result = ColorConverter.rgb2Hex(color); assertEquals(expResult, result); }