ColorUtility { public static Color fromHex(String hex) { int hashIdx = hex.indexOf("#"); String justHex = (hashIdx >= 0) ? hex.substring(hashIdx + 1) : hex; int hexIntValue = Integer.parseInt(justHex, 16); Color color = new Color(hexIntValue); return color; }  static String toHex(Color color); static String toHexLowercase(Color color); static Color fromHex(String hex);  }
@Test public void testFromHex() { String hex = "#00ff00"; Color expResult = Color.GREEN; Color result = ColorUtility.fromHex(hex); assertThat(expResult, is(equalTo(result))); }