JDateChooser setDateFormat 同时输入数据库
JDateChooser setDateFormat while input into database
ps.setString(26, ((JTextField) Birthday.getDateEditor().getUiComponent()).getText());
这是我的代码,我如何将日期格式转换为 MMM d,yyyy 因为我的 JDateChooser 的默认格式是 yyyy-MM-dd。
试试这个:
DateFormat f = new SimpleDateFormat("MMM d, yyyy");
ps.setString(26, f.format(((JTextField) Birthday.getDateEditor().getUiComponent()).getText()));
更正
DateFormat f = new SimpleDateFormat("MMM d, yyyy");
ps.setString(26, f.format(Birthday.getDate()));
ps.setString(26, ((JTextField) Birthday.getDateEditor().getUiComponent()).getText());
这是我的代码,我如何将日期格式转换为 MMM d,yyyy 因为我的 JDateChooser 的默认格式是 yyyy-MM-dd。
试试这个:
DateFormat f = new SimpleDateFormat("MMM d, yyyy");
ps.setString(26, f.format(((JTextField) Birthday.getDateEditor().getUiComponent()).getText()));
更正
DateFormat f = new SimpleDateFormat("MMM d, yyyy");
ps.setString(26, f.format(Birthday.getDate()));