更新时间:2023-02-18 23:19:27
例外情况是: java.util.Date
对象,而不是
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中引入了Time API .