title: insert date from excel file to mysql using spring boot
body: <p>I am trying to insert data from excel to database mysql using spring boot but i got problem with date .
  for example from excel i have 06/01/2019 but i found it in the DB 05/01/2019
  Could any one help me to solve this pleaaase :(</p>
  
  <p>This is my code :</p>
  
  <p>Formation.java</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  private String Cursus ;
  private String Groupe_Action;
    @Temporal(TemporalType.DATE)
  private Date Date ;
  private String  Module;
  private String  Formateur;
  private String Nombre_Appt;
  private String Nombre_d_absents;
  private String Honoraires_Formateurs_HT ;
  private String Jours_de_formation;
  private String Nbre_D_heures;
  private String Taux_h;
  private String Ristourne_Prévisionnelle ;
  private String Coûts_Hebergement_TTC;
  private String Coûts_Pause_Café_TTC;
  private String fileType;
  @Transient
  private MultipartFile file;
  </code></pre>
  
  <p>FormationFileServiceImpl.java</p>
  
  <pre><code>   @Service
    @Transactional
     public class FormationFileServiceImpl implements FormationFileService {
  
  @Autowired
  private FormationFileRepository formationFileRepository;
  @Override
  public List&lt;Formation&gt; findAll() {
      return (List&lt;Formation&gt;) formationFileRepository.findAll();
  }
  
  @Override
  public Boolean SaveDataFromFile(MultipartFile file) {
  
      Boolean isFalg=false;
     String extention = 
      FilenameUtils.getExtension(file.getOriginalFilename());
       if(extention.equalsIgnoreCase("xls") || 
      extention.equalsIgnoreCase("xlsx") ) {
          isFalg=readDataFromExcel(file);
      }
      return isFalg;
  }
  
  private Boolean readDataFromExcel(MultipartFile file) {
      Workbook workbook = getWorkBook(file);
       Sheet sheet = workbook.getSheetAt(0);
       Iterator&lt;Row&gt; rows = sheet.iterator();
  
      rows.next();
      while(rows.hasNext()) {
          Row row = rows.next();
          Formation formation = new Formation();
          if(row.getCell(0).getCellType() == 
       Cell.CELL_TYPE_STRING) {
  
     formation.setCursus(row.getCell(0).getStringCellValue());
          }
          if(row.getCell(1).getCellType() == Cell.CELL_TYPE_STRING) {
              formation.setGroupe_Action(row.getCell(1).getStringCellValue());
          }
          if(row.getCell(2).getCellType() == Cell.CELL_TYPE_NUMERIC) {
              formation.setDate(row.getCell(2).getDateCellValue());
  
          }if(row.getCell(3).getCellType() == Cell.CELL_TYPE_STRING) {
              formation.setModule(row.getCell(3).getStringCellValue());
  
          }if(row.getCell(4).getCellType() == Cell.CELL_TYPE_STRING) {
              formation.setFormateur(row.getCell(4).getStringCellValue());
  
          }if(row.getCell(5).getCellType() == Cell.CELL_TYPE_NUMERIC) {
              String Nombre_Appt = NumberToTextConverter.toText(row.getCell(5).getNumericCellValue());
               formation.setNombre_Appt(Nombre_Appt);
  
             }if(row.getCell(6).getCellType() == Cell.CELL_TYPE_NUMERIC) {
              String Nombre_d_absents = NumberToTextConverter.toText(row.getCell(6).getNumericCellValue());
              formation.setNombre_d_absents(Nombre_d_absents);
  
            }if(row.getCell(7).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String Horaire_Formateur_JH = NumberToTextConverter.toText(row.getCell(7).getNumericCellValue());
                  formation.setHonoraires_Formateurs_HT(Horaire_Formateur_JH);
  
                }if(row.getCell(8).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String Jour_formation = NumberToTextConverter.toText(row.getCell(8).getNumericCellValue());
                  formation.setJours_de_formation(Jour_formation);
  
                }if(row.getCell(9).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String Nombre_d_heures = NumberToTextConverter.toText(row.getCell(9).getNumericCellValue());
                  formation.setNbre_D_heures(Nombre_d_heures);
  
                }if(row.getCell(10).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String taux_h = NumberToTextConverter.toText(row.getCell(10).getNumericCellValue());
                  formation.setTaux_h(taux_h);
  
                }if(row.getCell(11).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String Ristourne_Prévisionnelle  = NumberToTextConverter.toText(row.getCell(11).getNumericCellValue());
                  formation.setRistourne_Prévisionnelle(Ristourne_Prévisionnelle);
  
                }if(row.getCell(12).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String Coûts_Hebergement_TTC  = NumberToTextConverter.toText(row.getCell(12).getNumericCellValue());
                  formation.setCoûts_Hebergement_TTC(Coûts_Hebergement_TTC);
  
                } if(row.getCell(13).getCellType() == Cell.CELL_TYPE_NUMERIC) {
                  String Coûts_Pause_Café_TTC = NumberToTextConverter.toText(row.getCell(13).getNumericCellValue());
                  formation.setCoûts_Pause_Café_TTC(Coûts_Pause_Café_TTC);
  
                }
  
  
          formation.setFileType(FilenameUtils.getExtension(file.getOriginalFilename()));
          formationFileRepository.save(formation);
      }
      return true;
  }
  
  private Workbook getWorkBook(MultipartFile file) {
      Workbook workbook = null;
        String extention = FilenameUtils.getExtension(file.getOriginalFilename());
         try {
             if(extention.equalsIgnoreCase("xlsx")) {
                 workbook =  new XSSFWorkbook(file.getInputStream());
  
             }else if (extention.equalsIgnoreCase("xls")) {
               workbook = new XSSFWorkbook(file.getInputStream());  
             }
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return workbook;
  }
  </code></pre>
  
  <p>FormationFileController.java</p>
  
  <pre><code>    @RestController
      public class FormationFileController {
        @Autowired
     private FormationFileService formationFileService;
  
    //@GetMapping(value = "/")
    //public String Home(Model model) {
    //    model.addAttribute("formation", new Formation());
     //   List&lt;Formation&gt; formation = formationFileService.findAll();
    //    model.addAttribute("formation", formation);
    //    return "view/pers";
    //    
    //}
   @PostMapping(value = "/fileupload")
     public ResponseEntity&lt;String&gt; uploadFile(@ModelAttribute Formation 
     formation,RedirectAttributes redirectAttributes) {
  String originalName = formation.getFile().getOriginalFilename();
  
  Boolean 
    isFlag=formationFileService.SaveDataFromFile(formation.getFile());
  
       if(isFlag==true) { 
          //           
          redirectAttributes.addFlashAttribute("successmessage","File upload 
          successfully!"); 
        //             }else { 
            //          
          redirectAttributes.addFlashAttribute("errormessage", "Please try 
       again !");
  
       }
          //return "redirect:/";
          return new ResponseEntity&lt;String&gt;(originalName, 
               HttpStatus.OK);
  
             }
  </code></pre>