Search code examples
javamysqlnetbeans-7jdatechooser

How can I set the date to the jDateChooser which is retrieved from the database?


I have a form on which I want to access a date from the database and show in jDateChooser for a particular record.

I saved the date as a string in the database.

How do I get the date from the database table and how do I set that date in jDateChooser?


Solution

  • If you stored the date in the database as String then you're going to need to retrieve it as String

    String dateValue = resultset.getString(...); // What ever column
    java.util.Date date = new SimpleDateFormat("dd-MM-yyyy").parse(dateValue);
    
    jDateChooser.setDate(date);