code: public static @NotNull String urlEncode(@Nullable String value) {
      if (value == null) {
        return "";
      }
      try {
        return URLEncoder.encode(value, CharEncoding.UTF_8);
      }
      catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
      }
    }
docs: Applies URL-Encoding to the given parameter name or value. Uses {@link URLEncoder#encode(String, String)} with
  UTF-8 character set, while avoiding the need to catch the UnsupportedEncodingException.
  @param value the parameter name or value to encode
  @return URL-encoded string - or empty string if the specified value was null
  @throws RuntimeException in the very unlikely case that UTF-8 is not supported on the current system