title: How to convert date to the format in which date is saved in MongoDB using Java and Spring?
body: <pre><code> @GetMapping("/{dateFrom}/{dateTo}")
         public List&lt;com.example.demo.attendance&gt; getRange(@PathVariable("dateFrom")  String dateFrom,@PathVariable("dateTo") String dateTo) throws ParseException{
            Date date1= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(dateFrom);
            Date date2= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(dateTo);
            System.out.println(date1);
            System.out.println(date2);
             List&lt;com.example.demo.attendance&gt; att =  this.attRepo.findDateBetween(date1,date2);
  
             return att;
          }
  </code></pre>
  
  <p>here i am trying tho convert the date in the format (yyyy-MM-dd) to the format in which date is saved in mongodb to perform queries</p>