title: How add LocalDate list to myList in Java
body: <p>How add Local date list to myList in java </p>
  
  <p>Please find the below code and check where I made a mistake to add dates to myList</p>
  
  <p>I declare List as Local date now need to convert to myModel</p>
  
  <p>error occurs in //  myList.addAll(employeeReportsModel.getReportFromDt());</p>
  
  <pre><code> @RequestMapping(value = "/getMusterRollDateBased", method = RequestMethod.GET)
   public ModelAndView getMusterRollDateBased(EmployeeReportsModel employeeReportsModel) {
      ModelAndView mv = new ModelAndView();
      String tablePrefix = "at_hr_logs_";
  
        try {
         System.out.println("refort from date.."+employeeReportsModel.getReportFromDt());
  
          System.out.println("refort to date.."+employeeReportsModel.getReportToDt());
          String fromdate = employeeReportsModel.getReportFromDt();
          String todate = employeeReportsModel.getReportToDt();
          Date date1 = new SimpleDateFormat("yyyy-MM-dd").parse(fromdate);
          Date date2 = new SimpleDateFormat("yyyy-MM-dd").parse(todate);
          System.out.println(date1 + "-----" + date2);            
          // parse the date into another format           
          SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd");           
          String fromdate1 = sdfDestination.format(date1);
          String todate1 = sdfDestination.format(date2);          
         employeeReportsModel.setReportFromDt(fromdate1);         
         // get dates between two dates           
         String startString = fromdate1;          
         String endString = todate1;
  
         LocalDate incrementingDate = LocalDate.parse(startString);
         LocalDate endDate = LocalDate.parse(endString);
         List&lt;LocalDate&gt; allDates = new ArrayList&lt;&gt;();
  
          while (!incrementingDate.isAfter(endDate)) {
              allDates.add(incrementingDate);
              incrementingDate = incrementingDate.plusDays(1);
          }
  
          System.err.println(allDates);
          List&lt;EmployeeReportsModel&gt; myList = null;   
          mv.addObject("allDates",allDates);
          for (LocalDate date : allDates) {
              //System.out.println();             
              System.out.println("dates is..." + date);
              employeeReportsModel.setReportFromDt(date.toString());              
              String[] parts = date.toString().split("-");
              String part1 = parts[0]; // 004
              String part2 = parts[1]; // 034556
              System.out.println("year ....." + part1);
              System.out.println("Month....." + part2);
  
              String tableName = tablePrefix + part1 + '_' + part2;
              System.out.println("hks table name is.." + tableName);
              employeeReportsModel.setDynamicTableName(tableName);
              myList.addAll(employeeReportsModel.getReportFromDt());
            //here we get a problem to add
  }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
      mv.setViewName("/" + moduleName + "/employeeMusterRollBasedOnDateInter");
      return mv;
  
  }
  </code></pre>