Here is my code, this is how should it work
- Listener listenes what is put in VIN textfield and reads this data
- I iterate through CarFx list, if VIN number I typed is the same as vin number in my list of rents program starts checking what are the dates that are not available for renting
- I am adding to my list unavailable dates
- Excluding from DatePicker above mentioned days
What I do wrong?
       List<LocalDate> unavailableDates = new ArrayList<>();
       unavailableDates.add(LocalDate.parse("2018-12-31")); //for example
        vinTextField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            System.out.println(" Text Changed to  " + newValue + ")\n");
        }
    });
    for (CarFx lcs : carFxList) {
        if (lcs.getVin().equals(vinTextField.getText())) {
            LocalDate da = lcs.getReleaseDate();
            int nr = lcs.getDays(); // number of days for which car is reserved
            for (int i = 1; i < nr; i++) {
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM d yyyy");
                unavailableDates.add(da);
                da.plusDays(i);
            }
        }
    }
    releaseDatePicker.setDayCellFactory(picker -> new DateCell() {
        @Override
        public void updateItem(LocalDate date, boolean empty) {
            super.updateItem(date, empty);
            LocalDate today = LocalDate.now();
            setDisable(empty || date.compareTo(today) < 0); // I am also excluding all days in the past
            if (date != null && !empty) {
                // Compare date to List
                if (unavailableDates.contains(date)) {
                    setDisable(true);
                }
            }
        }
    });
    this.releaseDatePicker.valueProperty()
            .bindBidirectional(this.carModel.getCarFxObjectProperty().releaseDateProperty());
 
    
