Пример #1
0
 private void handleBirthDateChange() {
   String bdateStr = view.bDateFld.getText();
   if (bdateStr == null || bdateStr.trim().equals("")) {
     model.setBirthDate(null);
     view.syncBirthDate();
   } else {
     try {
       DateTimeFormatter formatter = DateTimeFormatter.ofPattern(view.dateFormat);
       LocalDate bdate = LocalDate.parse(bdateStr, formatter);
       List<String> errorList = new ArrayList<>();
       if (model.isValidBirthDate(bdate, errorList)) {
         model.setBirthDate(bdate);
         view.syncAgeCategory();
       } else {
         this.showError(errorList);
         view.syncBirthDate();
       }
     } catch (DateTimeParseException e) {
       // Birth date is not in the specified date format
       List<String> errorList = new ArrayList<>();
       errorList.add("Birth date must be in the " + view.dateFormat.toLowerCase() + " format.");
       this.showError(errorList);
       // Refresh the view
       view.syncBirthDate();
     }
   }
 }
Пример #2
0
 private void saveData() {
   List<String> errorList = new ArrayList<>();
   boolean isSaved = model.save(errorList);
   if (!isSaved) {
     this.showError(errorList);
   }
 }