set Date In JavaFX Date Picker - Java JavaFX

Java examples for JavaFX:Date Picker

Description

set Date In JavaFX Date Picker

Demo Code


//package com.java2s;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import javafx.scene.control.DatePicker;

public class Main {
    public static void setDateInDatePicker(DatePicker datePicker, Date date) {
        if (date != null) {
            LocalDate localDate = date.toInstant()
                    .atZone(ZoneId.systemDefault()).toLocalDate();
            datePicker.setValue(localDate);
        }/*w ww .ja  va2s .c  om*/
    }
}

Related Tutorials