Last active
March 10, 2019 12:23
-
-
Save ezhov-da/dee842f60710c9817ad69bfe5d7062c8 to your computer and use it in GitHub Desktop.
java color to hex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/3607858/convert-a-rgb-color-value-to-a-hexadecimal | |
[code:]java[:code] | |
import java.util.logging.Logger; | |
import java.awt.Color; | |
/** | |
* Получаем HEX из цвета | |
* <p> | |
* @author ezhov_da | |
*/ | |
public class HexConverter | |
{ | |
private static final Logger LOG = Logger.getLogger(HexConverter.class.getName()); | |
private static final String PATTERN = "#%02x%02x%02x"; | |
public static String getHexFromColor(Color color) | |
{ | |
return String.format(PATTERN, color.getRed(), color.getGreen(), color.getBlue()).toUpperCase(); | |
} | |
} | |
[/code] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment