title: List of ZonedDateTime as request body with Spring
body: <p>I'm implementing a Spring <code>@RestController</code> with a <code>@PostMapping</code> annotated method. I want to allow a HTTP POST using this body:</p>
  
  <pre><code>{"dateTimes":[
    "2017-07-19T14:25+02:00",
    "2017-08-19T14:25+02:00"
  ]
  }
  </code></pre>
  
  <p>I have an object used as <code>@RequestBody</code>:</p>
  
  <pre><code>public class TransactionAllowedRequestBody {
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    private List&lt;ZonedDateTime&gt; dateTimes;
  
    public List&lt;ZonedDateTime&gt; getDateTimes() {
      return dateTimes;
    }
  
  
    public void setDateTimes(List&lt;ZonedDateTime&gt; dateTimes) {
      this.dateTimes = dateTimes;
    }
  }
  </code></pre>
  
  <p>This is my controller method:</p>
  
  <pre><code>@PostMapping("/transaction-allowed")
  public void isTransactionAllowed(@AuthenticationPrincipal CustomUserDetails userDetails,
                                   @RequestBody TransactionAllowedRequestBody requestBody) {
      System.out.println("requestBody = " + requestBody);
  }
  </code></pre>
  
  <p>However, when I try this, I get:</p>
  
  <pre><code>Could not read JSON document: Can not construct instance of java.time.ZonedDateTime: 
  no String-argument constructor/factory method to deserialize from String value ('2017-07-19T14:25+02:00')
  </code></pre>
  
  <p>If I replace <code>ZonedDateTime</code> with <code>String</code>, it works.</p>
  
  <p>I am using Spring Boot 1.5.3.</p>
  
  <p>Note: Using <code>@DateTimeFormat</code> on a GET request parameter works fine. I tried it with:</p>
  
  <pre><code>@GetMapping("/transaction-allowed")
  public void isTransactionAllowed(@AuthenticationPrincipal CustomUserDetails userDetails,
                                   @RequestParam("datetime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) ZonedDateTime dateTime) {
      System.out.println("userDetails = " + userDetails);
      System.out.println("dateTime = " + dateTime);
  }
  </code></pre>