Java Hex Convert To convertHexadecimal2RGB(final String hexColor, final String divider)

Here you can find the source of convertHexadecimal2RGB(final String hexColor, final String divider)

Description

convert Hexadecimal RGB

License

Open Source License

Declaration

public static String convertHexadecimal2RGB(final String hexColor,
            final String divider) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String convertHexadecimal2RGB(final String hexColor,
            final String divider) {
        final String hex = hexColor.replaceFirst("#", "");
        if (hex.length() != 6) {
            return null;
        }//ww  w .ja  v a  2  s.  co  m
        final StringBuilder sb = new StringBuilder();
        String toCon = hex.substring(0, 2);
        int color = Integer.parseInt(toCon, 16);
        sb.append(color);
        for (int i = 2; i < 6; i += 2) {
            toCon = hex.substring(i, i + 2);
            color = Integer.parseInt(toCon, 16);
            sb.append(divider);
            sb.append(color);
        }
        return sb.toString();
    }
}

Related

  1. convertHex(char c)
  2. convertHexa(String bool)
  3. convertHexByteToTelcoChar(byte byteValue)
  4. convertHexChars(final String value)
  5. convertHexColorToRgb(final String hex)
  6. convertHexFloatingPointLiteralToBits(char[] source)