我可以检索所有记录的完整日期,但我只想检索每条记录的日期。例如我有一个日期 2017-01-20,但我只想检索 20。我该怎么做?这是我的代码:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.format(calendar.getDate());
String sql = "SELECT reserve_date FROM reservation";
try
{
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
text.setText("");
while(rs.next()){
String str = rs.getString("reserve_date");
text.append(str);
text.append("\n");
}
pst.close();
rs.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
finally{
try{
rs.close();
pst.close();
}catch(Exception e){JOptionPane.showMessageDialog(null, e);}
}