java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.lang.String
时间: 2023-10-21 10:04:30 浏览: 508
This error occurs when you try to cast a Java SQL Timestamp object to a Java String object.
To fix this error, you need to convert the Timestamp object to a String. You can do this by using the toString() method of the Timestamp object or by using a SimpleDateFormat object to format the Timestamp object into a String.
Here's an example of how to convert a Timestamp object to a String:
```
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String dateString = timestamp.toString();
```
Alternatively, you can use SimpleDateFormat to format the Timestamp object into a String:
```
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = dateFormat.format(timestamp);
```
Make sure to use the appropriate format for your needs.
阅读全文