Dynamically update list of checkbox based on changing date (value) - java

I am trying to create a simple checklist with starting dates that responds to a time slider that specifies a date.
Each task has a start date.
Each task checkbox should only be rendered if the task start date has elapsed.
The checklist looks like this on initialize
How do i update the checklist to respond to the time slider?
I understand I need to add a listener somewhere or make a call to update the ui elements in the scene somewhere, but I am unsure where to begin.
I have tried updating the list used to create, but it doesn't update the UI elements because they have already been created.
ProjectChecklist.java
public class ProjectChecklist extends Application {
Group root = new Group();
Scene scene = new Scene(root, 600, 300);
VBox vbox = new VBox();
HBox hbox = new HBox();
ScrollPane scrollPane = new ScrollPane();
taskList = getAllTasks(PROJECT_FILENAME);
todayDate = LocalDate.now();
sliderStartDate = taskList.get(0).getStartDate();
LocalDate sliderEndDate = taskList.get(taskList.size() - 1).getEndDate();
long days = ChronoUnit.DAYS.between(sliderStartDate, sliderEndDate);
long daysFromToday = ChronoUnit.DAYS.between(sliderStartDate, todayDate);
slider = new Slider(0, days, 1);
slider.setValue(daysFromToday);
sliderValue = new Label(LocalDate.now().toString());
slider.setMajorTickUnit(1);
slider.setShowTickLabels(true);
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
slider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
double daysValue = Math.round(newValue.doubleValue());
LocalDate newDate = (sliderStartDate.plusDays((long) daysValue));
slider.setValue(daysValue);
sliderValue.setText(newDate.toString());
}
int taskNumber = 1;
for (ChecklistTask task : taskList) {
if (!task.getStartDate().isAfter(todayDate)) {
CheckBox newCB = new CheckBox();
newCB.setText("task " + taskNumber++ + ": " + task.getDescription());
vbox.getChildren().add(newCB);
}
}
vbox.getChildren().add(slider);
vbox.getChildren().add(sliderValue);
hbox.getChildren().add(vbox);
hbox.setSpacing(40);
hbox.setPadding(new Insets(10, 10, 10, 10));
scrollPane.setContent(hbox);
scrollPane.setPrefSize(600, 300);
scrollPane.setFitToHeight(true);
root.getChildren().add(scrollPane);
primaryStage.setTitle("Bennington checklist");
primaryStage.setScene(scene);
}
public static void main(String args[]) {
launch(args);
runApplication();
}
ChecklistTask.java
import java.time.LocalDate;
import java.util.UUID;
public class ChecklistTask{
private UUID id;
private String description;
private LocalDate startDate;
private LocalDate endDate;
public ChecklistTask() {
this.id = UUID.randomUUID();
}
public UUID getId() {
return id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LocalDate getEndDate() {
return endDate;
}
public void setEndDate(LocalDate endDate) {
this.endDate = endDate;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
}

I would suggest using a ListView which is backed by a FilteredList where the predicate compares the slider value to the ChequelistTask date. Changing the value of the slider will automatically update the predicate for filtering the list where the start date > the selected date of the slider. The filtering will take care of the list being updated accordingly, without having to rebuild the VBox content.
Here's an example of updating a predicate when something changes:
JavaFX FilteredList, filtering based on property of items in the list

Related

Create a listener logic for a custom combobox

I am trying to create a listener logic for a custom combo box that I have created that contains items with check boxes.
I was not able to proceed as I am not getting an idea on how to do it.
MainApplication.java
public class MainApplication extends Application{
#Override
public void start(Stage stage) {
Scene scene = new Scene(new VBox(), 450, 250);
ComboBox<ComboBoxItemWrap<Person>> cb = new ComboBox<>();
#SuppressWarnings("unchecked")
ObservableList<ComboBoxItemWrap<Person>> options = FXCollections.observableArrayList(
new ComboBoxItemWrap<>(new Person("A", "12-Aug-1994")),
new ComboBoxItemWrap<>(new Person("B", "13-Aug-1994")),
new ComboBoxItemWrap<>(new Person("C", "14-Aug-1994"))
);
cb.setCellFactory( c -> {
ListCell<ComboBoxItemWrap<Person>> cell = new ListCell<ComboBoxItemWrap<Person>>(){
#Override
protected void updateItem(ComboBoxItemWrap<Person> item, boolean empty) {
super.updateItem(item, empty);
if (!empty) {
final CheckBox cb = new CheckBox(item.toString());
cb.selectedProperty().bind(item.checkProperty());
setGraphic(cb);
}
}
};
cell.addEventFilter(MouseEvent.MOUSE_RELEASED, event -> {
cell.getItem().checkProperty().set(!cell.getItem().checkProperty().get());
StringBuilder sb = new StringBuilder();
cb.getItems().filtered( f-> f!=null).filtered( f-> f.getCheck()).forEach( p -> {
sb.append("; "+p.getItem());
});
final String string = sb.toString();
cb.setPromptText(string.substring(Integer.min(2, string.length())));
});
return cell;
});
cb.setItems(options);
VBox root = (VBox) scene.getRoot();
Button bt = new Button("test");
bt.setOnAction(event -> {
cb.getItems().filtered( f -> f.getCheck()).forEach( item -> System.out.println(item.getItem()));
});
root.getChildren().addAll(cb, bt);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
ComboBoxItemWrap.java
public class ComboBoxItemWrap<T> {
private BooleanProperty check = new SimpleBooleanProperty(false);
private ObjectProperty<T> item = new SimpleObjectProperty<>();
ComboBoxItemWrap() {
}
ComboBoxItemWrap(T item) {
this.item.set(item);
}
ComboBoxItemWrap(T item, Boolean check) {
this.item.set(item);
this.check.set(check);
}
public BooleanProperty checkProperty() {
return check;
}
public Boolean getCheck() {
return check.getValue();
}
public void setCheck(Boolean value) {
check.set(value);
}
public ObjectProperty<T> itemProperty() {
return item;
}
public T getItem() {
return item.getValue();
}
public void setItem(T value) {
item.setValue(value);
}
#Override
public String toString() {
return item.getValue().toString();
}
}
Person.java
public class Person {
private StringProperty name = new SimpleStringProperty();
private StringProperty birthday = new SimpleStringProperty();
public Person() {
}
public Person(String name, String birthday) {
setNameValue(name);
setBirthdayValue(birthday);
}
public StringProperty getNameProperty() {
return name;
}
public String getNameValue() {
return name.getValue();
}
public void setNameValue(String value) {
name.setValue(value);
}
public StringProperty getBirthdayProperty() {
return birthday;
}
public String getBirthdayValue() {
return birthday.getValue();
}
public void setBirthdayValue(String value) {
birthday.setValue(value);
}
#Override
public String toString() {
return getNameValue()+" ("+getBirthdayValue()+")";
}
}
In the output application, a list of items with check boxes will get populated. On selection of any number of entries in the list, the entry name gets populated on the combo box itself separated by a ';'. Now I want my back end code to listen and identify the entries that have been selected in order to perform further operations.
You may not need to reinvent the wheel. Consider using ControlsFX CheckComboBox.
That being said there are several problems in the code:
You never update the property on a selection of the CheckBox. This can be easily fixed by using bidirectional bindings.
Since the ComboBox popup is closed, the CheckBox is no longer armed at the time the MOUSE_RELEASED event is triggered. this is a prerequesite for the selected state of the CheckBox changing though. Modifying the skin allows you to change this behaviour.
You use ObservableList.filtered to create FilteredLists that you throw away immediately afterwards. You also create a filtered list of a filtered list in the MOUSE_RELEASED event filter. This is not wrong per se, but you're creating an expensive object there without the need to do so: simply get a stream there. This is a much more lightweight way to filter a list, if the result is only needed once. Use filtered/FilteredList only if you need an ObservableList that contains elements from another ObservableList and that is automatically updated.
Also note that there is a way to make an ObservableList trigger update changes on a change of a property: Use the observableArrayList method taking an extractor as parameter.
This is how you could rewrite your code to make it work:
VBox root = new VBox();
Scene scene = new Scene(root, 450, 250);
ComboBox<ComboBoxItemWrap<Person>> cb = new ComboBox<>();
ObservableList<ComboBoxItemWrap<Person>> options = FXCollections.observableArrayList(item -> new Observable[] {item.checkProperty()});
options.addAll(
new ComboBoxItemWrap<>(new Person("A", "12-Aug-1994")),
new ComboBoxItemWrap<>(new Person("B", "13-Aug-1994")),
new ComboBoxItemWrap<>(new Person("C", "14-Aug-1994")));
cb.setCellFactory(c -> new ListCell<ComboBoxItemWrap<Person>>() {
private final CheckBox cb = new CheckBox();
#Override
protected void updateItem(ComboBoxItemWrap<Person> item, boolean empty) {
ComboBoxItemWrap<Person> oldItem = getItem();
if (oldItem != null) {
// remove old binding
cb.selectedProperty().unbindBidirectional(oldItem.checkProperty());
}
super.updateItem(item, empty);
if (empty || item == null) {
setGraphic(null);
} else {
cb.selectedProperty().bindBidirectional(item.checkProperty());
cb.setText(item.toString());
setGraphic(cb);
}
}
});
// make sure popup remains open
ComboBoxListViewSkin<ComboBoxItemWrap<Person>> skin = new ComboBoxListViewSkin<>(cb);
skin.setHideOnClick(false);
cb.setSkin(skin);
cb.setItems(options);
cb.promptTextProperty().bind(Bindings.createStringBinding(() ->
options.stream().filter(ComboBoxItemWrap::getCheck).map(Object::toString).collect(Collectors.joining("; ")), options));
Note that if you want the popup to be closed after (de)selecting a checkbox, you could simply add a event filter for MOUSE_RELEASED for the checkbox that calls cb.arm() instead of modifying the skin.

GlazedList: using the set method to update eventlist displayed in table removes table selection

I am using GlazedList with JFX TableView.
I have the following code:
TableView<Person> table = new TableView<Person>();
table.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );
EventList<Person> person_list = new BasicEventList<Person>();
Map<int, Person> map;
public void updatePerson(Person p){
int personID = p.getID();
int index = person_list.indexOf( map.get(personID) );
Person person = person_list.get(index);
person.setFirstName(p.getFirstName());
person.setLastName(p.getLastName());
person_list.set(index, person);
}
Problem:
When selecting multiple rows in the table, and the method updatePerson is called, after "person_list.set(index, person);" is called, all my table selection except for the last selected row are un-selected.
When is "updatePerson" called?
This method is called every time my back-end receives an update and push this updated value to my front-end. It happens periodically every few seconds.
What i wish to achieve:
When user selects multiple row, the table will continue to reflect the updated values without deselecting my selected rows.
EDIT:
The following is a sample code i used to test.
public class ObservableJFXTableView extends Application {
private final TableView<Person> table = new TableView<>();
private FilterMatcherEditor filterMatcherEditor = new FilterMatcherEditor();
private EventList<Person> people;
private ObservableList<Person> data;
final HBox hb = new HBox();
public static void main(String[] args){
launch(args);
}
private void setupGlazedList(){
people = new BasicEventList<Person>();
ObservableElementList.Connector<Person> personCOnnector = GlazedLists.beanConnector(Person.class);
EventList<Person> observedPeople = new ObservableElementList<Person>(people, personConnector);
EventList<Person> filtered_list = new FilterList<Person(observedPeople, filterMatcherEditor);
data = new EventObservableList<Person>(filtered_list);
}
private void populatedList(){
people.add(new Person("Jacob", "Smith", "a#example.com"));
people.add(new Person("James", "Johnson", "b#example.com"));
people.add(new Person("Christopher", "Lim", "c#example.com"));
people.add(new Person("Emma", "Jones", "d#example.com"));
people.add(new Person("Michael", "Brown", "a#example.com"));
}
#Override
public void start(Stage stage){
Scene scene = new Scene(new Group());
stage.setTitle("Table View Example");
stage.setWidth(450);
stage.setHeight(550);
final Label label = new Label("Address Book");
label.setFont(new Font("Arial"), 20);
table.setEditable(true);
table.getSelectionModel().setSeletionMode(SelectionMode.MULTIPLE);
TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name");
firstNameCol.setMinWidth(100);
firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");
lastNameCol.setMinWidth(100);
lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
TableColumn<Person, String> emailCol = new TableColumn<>("Email");
emailCol.setMinWidth(100);
emailCol.setCellValueFactory(new PropertyValueFactory<>("email"));
setupGlazedList();
populatedList();
table.setItems(data);
table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
final Button editButton = new Button("Edit -> people.get(2)");
editButton.setOnAction((ActionEvent e) -> {
people.get(2).setFirstName("NewFirst");
people.get(2).setLastName("NewLast");
people.get(2).setEmail("NewEmail");
});
hb.getChildren().add(editButton);
hb.setSpacing(3);
final VBox vbox = new VBox();
vbox.setSpaceing(5);
vbox.setPadding(new Insets(10,0,0,10));
vbox.getChildren().addAll(filterMatcherEditor.getTextField(), label, table, hb);
((Group) scene.getRoot()).getChildren().addAll(vbox);
stage.setScene(scene);
stage.show();
}
private static class FilterMatcherEditor extends AbstractMatcherEditor<Person>{
private TextField tf;
public FilterMatcherEditor(){
tf = new TextField();
tf.textProperty().addListener((observable, oldValue, newValue) -> filterChanged());
}
public TextField getTextField(){
return tf;
}
public void filterChanged(){
if (tf.getText().isEmpty())
this.fireMatchAll();
else
this.fireChanged(new FilterMatcher(tf.getText()));
}
private static class FilterMatcher implements Matcher {
private final String textFieldInput;
public FilterMatcher(String text){
this.textFieldInput = text;
}
public boolean matched(Object obj){
final Person person = (Person) obj;
for (Object obj: person.getAll()){
String str = ((String) obj).toUpperCase();
if ( str.contains(textFieldInput.toUpperCase()))
return true;
}
return false;
}
}
}
public class Person {
private final SimpleStringProperty firstName;
private final SimpleStringProeprty lastName;
private final SimpleStringProperty email;
private final PropertyChangeSupport support = new PropertyChangeSupport(this);
private Person(String fName, String lName, String email){
this.firstName = new SimpleStringProperty(fName);
this.lastName = new SimpleStringProperty(lName);
this.email = new SimpleStringProperty(email);
}
public void addPropertyChangeListener(PropertyChangeListener l){
support.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(PropertyChangeListener l){
support.removePropertyChangeListener(l);
}
public String getFirstName(){
return firstName.get();
}
public void setFirstName(String str){
final String old = firstName.get();
firstName.set(str);
support.firePropertyCHange("firstName", old, str);
}
public String getLastName(){
return lastName.get();
}
public void setLastName(String str){
final String old = lastName.get();
lastName.set(str);
support.firePropertyCHange("lastName", old, str);
}
public String getEmail(){
return email.get();
}
public void setEmail(String str){
final String old = email.get();
email.set(str);
support.firePropertyCHange("email", old, str);
}
public List<String> getAll(){
List<String> strList = new ArrayList<String>();
strList.add(firstName.get());
strList.add(lastName.get());
strList.add(email.get());
return strList;
}
}
}
Try using shift click to select multiple row, then click on the edit button, the 3rd row will be updated but all multiple selected rows will be unselected, except for one row.
I think you would benefit from looking at my answer to a similar question: GlazedList update EventList in JTable
You should be able to update the items in the collection without having to get & set on the list itself.
Also, make sure you're using the proper event selection model to obtain the selected items. Then you won't need to maintain the map object.

editable listview with custom object

So I have a listview filled with Objects of the class Tree, I want to be able to edit and add new items of the class tree to the listview and if possible when an item is selected and I press the delete key it will delete the tree object from the listview. the first item in the listview is the item that when overwriten it add the new item to the listview and spawns a new overwritable tree on the top of the listview, an exemple of this with strings and I want it with tree objects
public void start(Stage primaryStage) {
simpleList = new ListView<>(FXCollections.observableArrayList("add new Tree here","Item1", "Item2", "Item3", "Item4"));
simpleList.setEditable(true);
simpleList.setCellFactory(TextFieldListCell.forListView());
simpleList.setOnEditCommit(new EventHandler<ListView.EditEvent<String>>() {
#Override
public void handle(ListView.EditEvent<String> t) {
simpleList.getItems().set(t.getIndex(), t.getNewValue());
if (t.getIndex() == 0){
simpleList.getItems().add(0,"add new tree here");
}
}
});
simpleList.setOnEditCancel(new EventHandler<ListView.EditEvent<String>>() {
#Override
public void handle(ListView.EditEvent<String> t) {
System.out.println("setOnEditCancel");
}
});
BorderPane root = new BorderPane();
root.setCenter(simpleList);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public class Tree {
private int id;
public int getId() {
return id;
}
private String name;
public String getName() {
return name;
}
public Tree(int id, String name){
this.id = id;
this.name = name;
}
public String toString() {
return this.getName();
}
}
I know how to let it work with strings but don't know how I can make it work with custum objects, already searched and found I had to use a Callback object but can't manage to let it work, even after trying for serveral hours.
Thanks in advance!
You'll probably have to handle setting id of those objects somehow, but I hope this is what you were looking for
Start method:
public void start(Stage primaryStage) {
ListView<Tree> simpleList = new ListView<>(FXCollections.observableArrayList(new Tree(0, "add new tree here"), new Tree(1, "Tree one"), new Tree(2, "Tree two"), new Tree(1, "Tree three"), new Tree(1, "Tree four"), new Tree(1, "Tree five")));
simpleList.setEditable(true);
simpleList.setCellFactory(listView -> {
TextFieldListCell<Tree> cell = new TextFieldListCell<>();
cell.setConverter(new StringConverter<Tree>() {
#Override
public String toString(Tree tree) {
return tree.getName();
}
#Override
public Tree fromString(String string) {
Tree tree = cell.getItem();
tree.setName(string);
return tree;
}
});
return cell;
});
simpleList.setOnEditCommit(t -> {
simpleList.getItems().set(t.getIndex(), t.getNewValue());
if (t.getIndex() == 0) {
simpleList.getItems().add(0, new Tree(0, "add new tree here"));
}
});
// init delete item handler
simpleList.setOnKeyReleased(event -> {
if (event.getCode().equals(KeyCode.DELETE)) {
Tree selectedItem = simpleList.getSelectionModel().getSelectedItem();
simpleList.getItems().remove(selectedItem);
System.out.println(selectedItem + " deleted from list");
}
});
simpleList.setOnEditCancel(t -> System.out.println("setOnEditCancel"));
BorderPane root = new BorderPane();
root.setCenter(simpleList);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
Tree class:
public class Tree {
private int id;
private String name;
public Tree(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return this.getName();
}
}

JavaFx: show DatePicker

I have a ComboBox<MyItem> and I want to show a DatePicker when I select a special item from the ComboBox. I created a class that extends ComboBox, and I have a DatePicker in that class. I have added a listener to its selectedItemProperty:
public class CustomComboBox extends ComboBox<MyItem>{
private DatePicker datePicker;
public CustomComboBox(){
getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (MyItem.DATE.equals(newValue)) {
initDatePicker();
datePicker.show();
datePicker.requestFocus();
}
});
}
private void initDatePicker() {
if (datePicker == null) {
datePicker = new DatePicker();
datePicker.setFocusTraversable(false);
}
}
}
So if I select the DATE item the DatePicker should pop up and If I select a date I want to add as the value of the ComboBox
First of all why the datePicker not pops up? The second question is this posible to add the selected date to comboBox as value.
I assume you need something like this:
I did it by using a popup class from ControlsFX library.
Play with this demo app to understand the main idea.
import org.controlsfx.control.PopOver;
// here all other needed dependencies
public class Main extends Application {
private static final String DATE_TYPE = "DATE";
private class ComboBoxNode {
private Object value;
private String type;
private ComboBoxNode(final Object value, final String type) {
this.value = value;
this.type = type;
}
#Override
public String toString() {
return Objects.toString(value);
}
}
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) {
final ObservableList<ComboBoxNode> items =
FXCollections.observableArrayList(
new ComboBoxNode(LocalDate.now(), DATE_TYPE),
new ComboBoxNode("11:35AM", "TIME"));
final PopOver datePopOver = new PopOver();
datePopOver.setTitle("Enter new date");
datePopOver.setCornerRadius(10);
datePopOver.setHeaderAlwaysVisible(true);
datePopOver.setCloseButtonEnabled(true);
datePopOver.setAutoHide(true);
final ComboBox<ComboBoxNode> customComboBox = new ComboBox<>(items);
customComboBox.getSelectionModel().selectedItemProperty().addListener((o, old, newNode) -> {
if (newNode != null) {
if (newNode.type.equals(DATE_TYPE)) {
final DatePicker datePicker = new DatePicker((LocalDate) newNode.value);
datePicker.valueProperty().addListener((obs, oldDate, newDate) -> {
items.set(customComboBox.getSelectionModel().getSelectedInde‌​x(), new ComboBoxNode(newDate, DATE_TYPE));
datePopOver.hide();
});
final StackPane stackPane = new StackPane(datePicker);
stackPane.setPadding(new Insets(10, 10, 10, 10));
datePopOver.setContentNode(stackPane);
datePopOver.show(customComboBox);
} else {
datePopOver.hide();
}
}
});
final FlowPane pane = new FlowPane(customComboBox);
pane.setPadding(new Insets(10, 10, 10, 10));
pane.setPrefWidth(400);
pane.setPrefHeight(300);
// Show Scene
final Scene scene = new Scene(pane);
primaryStage.setTitle("Popup calendar");
primaryStage.setScene(scene);
primaryStage.show();
}
}

compare java fx date picker date to sql date inside a query

I want to know how I can compare a mysql date to a java fx date picker date. So if I have a datepicker date in MM/DD/YYYY format and a mysql date in YYYY/MM/DD format how do I compare those two inside a query?
I prepared for you small appliaction how to convert Date to LocalDate and set in DatePicker, how to take LocalDate from DatePicker and convert to Date. You can also check that date are the same.
public class Main extends Application {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
private Date dateUtil = sdf.parse("2016/09/25");
public Main() throws ParseException {
}
#Override public void start(Stage primaryStage) throws Exception {
Button button = new Button("Take date from DatePicker");
Label labelCompare = new Label();
Label labelCompare2 = new Label();
DatePicker datePicker = new DatePicker();
//convert Date to LocalDate
LocalDate localDate = dateUtil.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
//set in DatePicker
datePicker.setValue(localDate);
VBox hBox = new VBox();
hBox.getChildren().addAll(datePicker, button, labelCompare, labelCompare2);
Scene scene = new Scene(hBox, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
button.setOnAction(new EventHandler<ActionEvent>() {
#Override public void handle(ActionEvent e) {
//Take LocalDate from DatePicker
LocalDate localDate = datePicker.getValue();
//Convert LocalDate to Date
Date dateFromPicker = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
//compare
labelCompare.setText("Compare date: " + dateUtil.compareTo(dateFromPicker));
}
});
}
public static void main(String[] args) {
launch();
}
}
Easiest way:
String searched_date = datePicker.getValue().toString();
Date dateFromPicker = Date.valueOf(searched_date);

Categories