code: public static byte[] encodeBcd(String data, int num_bytes) {
          // allocate buffer
          byte buf[] = new byte[num_bytes];
  
          // if length of addr is odd, then add an F onto the end of it
          if ((data.length() % 2) != 0) {
              data += "F";
          }
  
          int index = 0;
          for (int i = 0; i < data.length(); i += 2) {
              StringBuilder x = new StringBuilder(data.substring(i, i + 2));
              x.reverse();
              buf[index] = ByteUtil.decodeHex(x.toString(), 2)[0];
              index++;
          }
  
          return buf;
      }
docs: BCD encodes a String into a byte array.