我有2个jdatechooser,一个是datefrom,另一个是dateto。我想在这两个jdatechooser的范围内过滤我的jTable数据。我的问题是每当我尝试过滤表(日期在我的jdatechoosers范围内)时,我的表就变空了。
SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy");
String from = (String) sdf.format(txt_datefrom.getDate());
String to = (String) sdf.format(txt_dateto.getDate());
try {
String sql = "select reference, name, date, time, totalAmount, "
+ "discount, status from receipts where date "
+ "between '" + from + "' and '" + to + "' ";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
table_audit.setModel(DbUtils.resultSetToTableModel(rs));
total();
} catch (Exception e) {
}