If i defined a color in resources
#123456
it\'s possible
It works for me!
String.format("#%06x", ContextCompat.getColor(this, R.color.my_color) & 0xffffff)