title: Spring Boot Search Data by Date (formated in ZonedDateTime)
body: <p>I want to get list of forms submitted on a particular date. Date will be passed by Admin in Search box (from front end it will be String but in Back end it's <code>ZonedDateTime</code>). </p>
  
  <p>I've written method in Repository as:</p>
  
  <pre><code>List&lt;AdmissionForm&gt; findByDateContains(ZonedDateTime datePart);
  </code></pre>
  
  <p>method formation ref : <a href="https://www.petrikainulainen.net/programming/spring-framework/spring-data-jpa-tutorial-creating-database-queries-from-method-names/" rel="nofollow noreferrer">https://www.petrikainulainen.net/programming/spring-framework/spring-data-jpa-tutorial-creating-database-queries-from-method-names/</a></p>
  
  <p>My Service class background logic is like:</p>
  
  <pre><code>@Transactional(readOnly = true)
  public List&lt;AdmissionFormDTO&gt; findByDate(ZonedDateTime datepart){
      return admissionFormRepository.findByDateContains(datepart).stream()
          .map(admissionFormMapper::toDto)
          .collect(Collectors.toList());
  }
  </code></pre>
  
  <p>And My Resource endpoint is like:</p>
  
  <pre><code>@GetMapping("/admissionForms/date")
  @Timed
  public List&lt;AdmissionFormDTO&gt; findByDate(@RequestParam("date") String date){
      log.debug("REST request to get AdmissionForms by searchTerm :" + date);
      //String to ZonedDateTime method conversion from seperate class
      ZonedDateTime zDate = SupportUtils.convertStringDateToZoneDateTime(date);
      return admissionFormService.findByDate(zDate);
  }
  </code></pre>
  
  <p>I've tried with String search terms and it's working fine but got only trouble with Searching with Date. </p>
  
  <p>I got the exception like:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Parameter value [%2018-11-20T00:00Z%] did not match expected type [java.time.ZonedDateTime (n/a)]' and exception = 'Parameter value [%2018-11-20T00:00Z%] did not match expected type [java.time.ZonedDateTime (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [%2018-11-20T00:00Z%] did not match expected type [java.time.ZonedDateTime (n/a)]'
  </code></pre>
  
  <p>Give some corrections so I can do search by Date as expected.</p>
  
  <p><strong><em>EDITED:</em></strong>
  I changed datatype from <code>ZoneDateTime</code> to <code>LocalDate</code> and solve accordingly as below (Skip timing for now):</p>
  
  <p>My Repository code:</p>
  
  <pre><code>List&lt;AdmissionForm&gt; findByDate(LocalDate datePart);
  </code></pre>
  
  <p>My Service Class:</p>
  
  <pre><code>@Transactional(readOnly = true)
  public List&lt;AdmissionFormDTO&gt; findByDate(String datepart){
      LocalDate localDatePart = SupportUtils.convertStringDateToLocalDate(datepart);
      return admissionFormRepository.findByDate(localDatePart).stream()
          .map(admissionFormMapper::toDto)
          .collect(Collectors.toList());
  }
  </code></pre>
  
  <p>My Resource Entry Point:</p>
  
  <pre><code>@GetMapping("/admissionForms/date")
  @Timed
  public List&lt;AdmissionFormDTO&gt; findByDate(@RequestParam("date")String date){
      log.debug("REST request to get AdmissionForms by searchTerm :{}",date);
      return admissionFormService.findByDate(date);
  }
  </code></pre>
  
  <p>Thanks for your suggestions, but can't find a way to work with <code>ZondDateTime</code> so we change requirements little bit. Hope others will get help from question and suggested answers here.  </p>