Reputation: 1613
I have a situation that I need to fill the jDateChooser
box by the current date automatically (without clicking the pop up calender).
How can I do that?
Thanks in advance.
Upvotes: 3
Views: 16994
Reputation: 1613
To pick up the current date with desired format (format is necessary when you work with database) -
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
Then just set it to the jdatechooser
field
jDateChooser.setDate(date);
Upvotes: 0
Reputation: 31
Here, the Date class belongs to the java.util package. So, either import java.util.Date or use:
java.util.Date date = new java.util.Date();
dateChooser.setDate(date);
Upvotes: 0