我正在尝试将从我的 sqlite 数据库获取的 sql.date 转换为 util.date。我想将该日期设置为 JDateChooser。我已经尝试了所有可能的方法,但似乎我错过了一些东西。谁能告诉我怎么了?
try{
String query = "select * from SkaterInfo where reg_no = ?";
pst = con.prepareStatement(query);
pst.setInt(1, num1);
rs = pst.executeQuery();
while(rs.next()){
name = rs.getString("Name");
surname = rs.getString("Surname");
batch = rs.getInt("Batch");
cell = rs.getLong("Mobile_No");
date = rs.getDate("Birth_Date");
}
pst.close();
rs.close();
}catch(Exception a){
JOptionPane.showMessageDialog(null, "Exception");
}
java.sql.Date date1 = new java.sql.Date(date.getTime());
dateChooser.setBounds(150, 150, 150, 30);
dateChooser.setDateFormatString("yyyy-MM-dd");
dateChooser.setDate(date1);
frame.getContentPane().add(dateChooser);