Search code examples
javastringdategetdatejdatechooser

get date and display in a lable? And how can i convert it to a string(date)


I want this date which have picked form jdateChooser to converted into string and displayed init jlable

java.util.Date date = jDateChooser1.getDate();
date.toInstant();
jLabel16.setText(date);

Solution

  • Use the toString() method, it converts an object to a String, do this jLabel16.setText(date.toString()); to display the contents of the object in the label.