code: @Nullable
    public static String urlEncode(String s)
    {
      if (s == null) {
        return null;
      }
  
      try {
        return StringUtils.replace(URLEncoder.encode(s, "UTF-8"), "+", "%20");
      }
      catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
    }
docs: Encodes a String in application/x-www-form-urlencoded format, with one exception:
  "+" in the encoded form is replaced with "%20".
  
  application/x-www-form-urlencoded encodes spaces as "+", but we use this to encode non-form data as well.
  
  @param s String to be encoded
  @return application/x-www-form-urlencoded format encoded String, but with "+" replaced with "%20".