title: DatePicker: how to customize
body: <p>I have the simple code for date picker which disables all the dates which are before the chosen one, but I need to be able to disable other dates as well (like for example:17.10.2014 until 19.10.2014). How could I change it in a way that specific dates are also disabled?</p>
  <pre><code>public class DatePickerSample extends Application {
  
  private Stage stage;
  private DatePicker checkInDatePicker;
  private DatePicker checkOutDatePicker;
  
  public static void main(String[] args) {
      Locale.setDefault(Locale.US);                  
      launch(args);
  }
  
  @Override
  public void start(Stage stage) {
      this.stage = stage;
      stage.setTitle(&quot;DatePickerSample &quot;);
      initUI();
      stage.show();
  }
  
  private void initUI() {
      VBox vbox = new VBox(20);
      vbox.setStyle(&quot;-fx-padding: 10;&quot;);
      Scene scene = new Scene(vbox, 400, 400);
      stage.setScene(scene);
      checkInDatePicker = new DatePicker();
      checkOutDatePicker = new DatePicker();
      checkInDatePicker.setValue(LocalDate.now());
      final Callback&lt;DatePicker, DateCell&gt; dayCellFactory = 
          new Callback&lt;DatePicker, DateCell&gt;() {
              @Override
              public DateCell call(final DatePicker datePicker) {
                  return new DateCell() {
                      @Override
                      public void updateItem(LocalDate item, boolean empty) {
                          super.updateItem(item, empty);
                          if (item.isBefore(
                                  checkInDatePicker.getValue().plusDays(1))
                              ) {
                                  setDisable(true);
                                  setStyle(&quot;-fx-background-color: #ffc0cb;&quot;);
                          }
                          long p = ChronoUnit.DAYS.between(
                                  checkInDatePicker.getValue(), item
                          );
                          setTooltip(new Tooltip(
                              &quot;You're about to stay for &quot; + p + &quot; days&quot;)
                          );
                  }
              };
          }
      };
      checkOutDatePicker.setDayCellFactory(dayCellFactory);
      checkOutDatePicker.setValue(checkInDatePicker.getValue().plusDays(1));
      GridPane gridPane = new GridPane();
  
      gridPane.setHgap(10);
      gridPane.setVgap(10);
      Label checkInlabel = new Label(&quot;Check-In Date:&quot;);
      gridPane.add(checkInlabel, 0, 0);
      GridPane.setHalignment(checkInlabel, HPos.LEFT);
      gridPane.add(checkInDatePicker, 0, 1);
      Label checkOutlabel = new Label(&quot;Check-Out Date:&quot;);
      gridPane.add(checkOutlabel, 0, 2);
      GridPane.setHalignment(checkOutlabel, HPos.LEFT);
      gridPane.add(checkOutDatePicker, 0, 3);
      vbox.getChildren().add(gridPane);
   }
  }
  </code></pre>