更新时间:2023-02-18 22:52:44
正如异常所说:Calendar::getTime()
返回一个 java.util.Date
对象,而不是 java.sql.Timestamp
对象.所以你不能将它转换为 Timestamp 对象.
As the exception says: Calendar::getTime()
returns a java.util.Date
object, not a java.sql.Timestamp
object. So you cannot cast it to a Timestamp object.
用途:
Timestamp timestamp = new Timestamp(cal.getTimeInMillis());
并且还考虑替换 Calendar
带有新的 日期 &Java SE 8 中引入的时间 API.