You can convert Date to String and then use > to compare, as follows
String sql = "SELECT * FROM todo WHERE create_date > ? "; PreparedStatement preStat = connection.prepareStatement(sql); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); preStat.setString(1, sdf.format(date)); ResultSet rs = preStat.executeQuery();
The incoming date string is directly judged by equivalence
Manual
JDBC
拼装SQL
words:I tried it
2016/11/19 09:29:11
和20161119092911
It seems to work, but I still recommend that you use whatever form is in the table.You can convert Date to String and then use > to compare, as follows