stringdatejcalendar

Date from SQL datebase to JCalander


I used http://toedter.com/ jDateChooser to get the date from user. But now I want to reset the selected date to the calendar from SQL database. This is the code I wrote to put selected date to database.

pst.setString(5, ((JTextField)datead.getDateEditor().getUiComponent()).getText());

Solution

  • I figured it out myself.

    java.util.Date dateadx = new SimpleDateFormat("yyyy-MM-dd").parse(dateadm);
    

    Here dateadm is the String variable which you want to store as date in JDateChooser.

    Then you can simply call

    datead.setDate(dateadx)
    

    to set the date.