code: public static byte[] stringToUid(final String uid, final short uid_length) {
      if (uid == null || uid.isEmpty()) {
        throw new IllegalArgumentException("UID was empty");
      }
      String id = uid;
      if (uid_length > 0) {
        while (id.length() < uid_length * 2) {
          id = "0" + id;
        }
      } else {
        if (id.length() % 2 > 0) {
          id = "0" + id;
        }
      }
      return DatatypeConverter.parseHexBinary(id);
    }
docs: Converts a hex string to a byte array
  If the {@code uid} is less than {@code uid_length * 2} characters wide, it
  will be padded with 0s to conform to the spec. E.g. if the tagk width is 3
  and the given {@code uid} string is "1", the string will be padded to
  "000001" and then converted to a byte array to reach 3 bytes.
  All {@code uid}s are padded to 1 byte. If given "1", and {@code uid_length}
  is 0, the uid will be padded to "01" then converted.
  @param uid The UID to convert
  @param uid_length An optional length, in bytes, that the UID must conform
  to. Set to 0 if not used.
  @return The UID as a byte array
  @throws NullPointerException if the ID was null
  @throws IllegalArgumentException if the string is not valid hex
  @since 2.0