java.util.Date vs java.sql.Date

前端 未结 7 2036
青春惊慌失措
青春惊慌失措 2020-11-22 05:13

java.util.Date vs java.sql.Date: when to use which and why?

7条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 05:53

    I had the same issue, the easiest way i found to insert the current date into a prepared statement is this one:

    preparedStatement.setDate(1, new java.sql.Date(new java.util.Date().getTime()));
    

提交回复
热议问题