I am new with jxDatePicker. I work with netbeans picked jxDatePicker and selected date.
Display (Wed 11/05/2014) format.
How to set jxDatePicker format("yyyy-MM-dd")(expect).And how to get the value and set in jLabel.
JXDatePicker datePicker = new JXDatePicker();
datePicker.setFormats("yyyy-MM-dd");
I tried code but not working.
private void jXDatePicker1ActionPerformed(java.awt.event.ActionEvent evt) {
Calendar cals = Calendar.getInstance();
SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
formater.format(jXDatePicker1.getDate());
jLabel.setText(formater.format(cals.getTime()));
}
我认为您需要在setFormats()
调用中放置一个String数组。
datePicker.setFormats(new String[]{"yyyy-MM-dd"});
//here the code to get value of jxdatepicker in normal date format
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
jxdatepicker.setFormats(dateFormat);
DateFormat sysDate = new SimpleDateFormat("dd/MM/yyyy");
String date_to_store = sysDate.format(d1.getDate()).toString();
System.out.println(date_to_store);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.