title: Spring NumberFormatException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Long
body: <p>I'm not sure if I'm missing something really basic but this is what I would like to do.</p>
  
  <p>I would like to make a rest API call to this address:</p>
  
  <p><a href="https://localhost:8080/fetchlocation?lat=-26.2041028&amp;lng=28.0473051&amp;radius=500" rel="noreferrer">https://localhost:8080/fetchlocation?lat=-26.2041028&amp;lng=28.0473051&amp;radius=500</a></p>
  
  <p>My rest method is:</p>
  
  <pre><code>public void fetchlocation(@RequestParam Long lat, @RequestParam Long lng, @RequestParam int radius){ //fetches location}
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>"timestamp": 1442751996949,   "status": 400,   "error": "Bad Request",
    "exception": "org.springframework.beans.TypeMismatchException",<br>
    "message": "Failed to convert value of type 'java.lang.String' to
    required type 'java.lang.Long'; nested exception is
    java.lang.NumberFormatException: For input string: \"-26.2041028\"",<br>
    "path": "/fetchlocation"</p>
  </blockquote>
  
  <p>I guess it is because rest API receives the co-ordinates as Strings instead of Longs when I make the GET call. How do I ensure that the rest API gets the Longs and not the String value when the call is made?</p>
  
  <p>I could easily get the method to work when I change the rest API method to take Strings as the parameters, but for type checking, I would prefer to use Longs.</p>
  
  <pre><code>public void fetchlocation(@RequestParam String lat, @RequestParam String lng, @RequestParam String radius){ //fetches location}
  </code></pre>