String (final @NotNull Color c, final boolean withAlpha) { final String R = Integer.toHexString(c.getRed()); final String G = Integer.toHexString(c.getGreen()); final String B = Integer.toHexString(c.getBlue()); final String rgbHex = (R.length() < 2 ? "0" : "") + R + (G.length() < 2 ? "0" : "") + G + (B.length() < 2 ? "0" : "") + B; if (!withAlpha) { return rgbHex; } final String A = Integer.toHexString(c.getAlpha()); return rgbHex + (A.length() < 2 ? "0" : "") + A; }