Reputation: 206
I have a date_picker from toedter.com from jcalendar package which are swing components. How can I set an initial value to it? I'm using netbeans.
I added the date_picker on design view and tried this on my source code :
UtilDateModel model = new UtilDateModel();
model.setDate(2014, 8, 24);
model.setSelected(true);
but I've been playing around where to put it still doesn't seem to work.
Any idea guys?
Upvotes: 1
Views: 7929
Reputation: 81
This should solve it:
UtilDateModel model = new UtilDateModel();
model.setDate( 2014, 8, 24 );
startDatePicker = new JDatePickerImpl(
new JDatePanelImpl( model ), new DateLabelFormatter() );
Upvotes: 0
Reputation: 480
You can try this out :
String dateValue = "initial date value"; // must be in (yyyy- mm- dd ) format
Date date = new SimpleDateFormat("yyyy-mm-dd").parse(dateValue);
jDateChooser.setDate(date);
Upvotes: 3