title: Strange url encoding issue
body: <p>I have a strange issue with urlencoding a plus sign <code>+</code> as a query param for a request against an API. The API's documentation states:</p>
  
  <blockquote>
    <p>The date has to be in the W3C format, e.g. '2016-10-24T13:33:23+02:00'.</p>
  </blockquote>
  
  <p>So far so good, so I'm using this code (minimalized) to generate the url, using Spring's UriComponentBuilder:</p>
  
  <pre><code>DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX");
  ZonedDateTime dateTime = ZonedDateTime.now().minusDays(1);
  String formated = dateTime.format(formatter);
  
  UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(baseUrl);
  uriComponentsBuilder.queryParam("update", formated);
  uriComponentsBuilder.build();
  String url = uriComponentsBuilder.toUriString();
  </code></pre>
  
  <hr>
  
  <p>The unencoded query would look like this:</p>
  
  <pre><code>https://example.com?update=2017-01-05T12:40:44+01
  </code></pre>
  
  <hr>
  
  <p>The encoded string results in:</p>
  
  <pre><code>https://example.com?update=2017-01-05T12:40:44%2B01
  </code></pre>
  
  <p>which is (IMHO) a correctly encoded query String. See the <code>%2B</code> replacing the <code>+</code> in <code>+01</code> at the end of the query string.</p>
  
  <p>Now, however, when I send the request against the API using the encoded url, I get an error saying the request could not be handled.</p>
  
  <p>If however, I replace the <code>%2B</code> with a <code>+</code> before sending the request, it works:</p>
  
  <pre><code>url.replaceAll("%2B", "+");
  </code></pre>
  
  <p>From my understanding, the <code>+</code> sign is a replacement for a <code>whitespace</code>. So the url that the server really sees after decoding must be </p>
  
  <pre><code>https://example.com?update=2017-01-05T12:40:44 01
  </code></pre>
  
  <ul>
  <li><p>Am I right with this assumption?</p></li>
  <li><p>Is there anything I can do, other than contacting the API's owner to make it work using the correctly encoded query, other than strange non standard string replacements?</p></li>
  </ul>
  
  <p>UPDATE:</p>
  
  <p>According to the specification <a href="http://www.ietf.org/rfc/rfc3986.txt" rel="noreferrer">RFC 3986</a> (Section 3.4), the <code>+</code> sign in a query param doesn't need to be encoded.</p>
  
  <blockquote>
    <p>3.4.  Query</p>
    
    <p>The query component contains non-hierarchical data that, along with
    data in the path component (Section 3.3), serves to identify a<br>
    resource within the scope of the URI's scheme and naming authority<br>
    (if any).  The query component is indicated by the first question<br>
    mark ("?") character and terminated by a number sign ("#") character<br>
    or by the end of the URI.</p>
    
    <p>Berners-Lee, et al.         Standards Track                    [Page
    23]  RFC 3986                   URI Generic Syntax<br>
    January 2005</p>
  
  <pre><code>  query       = *( pchar / "/" / "?" )
  </code></pre>
    
    <p>The characters slash ("/") and question mark ("?") may represent
    data    within the query component.  Beware that some older, erroneous
    implementations may not handle such data correctly when it is used as 
    the base URI for relative references (Section 5.1), apparently<br>
    because they fail to distinguish query data from path data when<br>
    looking for hierarchical separators.  However, as query components<br>
    are often used to carry identifying information in the form of<br>
    "key=value" pairs and one frequently used value is a reference to<br>
    another URI, it is sometimes better for usability to avoid percent-<br>
    encoding those characters.</p>
  </blockquote>
  
  <p>According to <a href="https://stackoverflow.com/questions/18138011/url-encoding-using-the-new-spring-uricomponentsbuilder/#21460758">this answer on stackoverflow</a>, spring's UriComponentBuilder uses this specification, but appearently it doesn't really. So a new question would be, how to make UriComponentBuilder follow the specs?</p>