Issue
It’s my first post,
I have a problem i have a sql.Timestamp in my List and i want to do set the value
of a the timestamp in a String
setModificationDate(listDossier.get(12));
The problem is when i try it i have an
java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.lang.String
I tried to do an setModificationDate(listDossier.get(12).toString()); but i didnt’t work too.
https://i.stack.imgur.com/mgFN4.png
setModificationDate is just an String.
Thanks for the help
Solution
Use DateFormatter. Example:
String pattern = "MMM dd, yyyy HH:mm:ss.SSSSSSSS";
String timestampAsString = "Nov 12, 2018 13:02:56.12345678";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
LocalDateTime localDateTime = LocalDateTime.from(formatter.parse(timestampAsString));
Answered By – Aaina Arora
Answer Checked By – Mary Flores (BugsFixing Volunteer)