code: public static byte[] encodeHexStringToBCD(String hexString) {
          hexString=hexString.toLowerCase();
          int noOfDigits = hexString.length();
  
          boolean isOdd = noOfDigits % 2 == 0 ? false : true;
          int noOfBytes = noOfDigits / 2;
          if (isOdd) {
              noOfBytes++;
          }
          byte[] bcdDigits = new byte[noOfBytes];
  
          char[] chars = hexString.toCharArray();
          int digit = -1;
          for (int i = 0; i< noOfDigits; i++) {
              digit = Character.digit(convertTelcoCharToHexDigit(chars[i]), 16);
              byte tmpByte = (byte) digit;
              if (i % 2 == 0) {
                  bcdDigits[i / 2] = tmpByte;
              } else {
                  bcdDigits[i / 2] |= (byte) (tmpByte << 4);
              }
          }
  
          return bcdDigits;
      }
docs: Encodes hex digits string into BCD digits. Supports specific telco chars '*' and '#'.
  
  @param hexString hex digit string to be encoded
  @return BCD even or odd encoded digits