[SOLVED] How to convert a TimeStamp in a List<String> to String?


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


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.


setModificationDate is just an String.

Thanks for the help


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)

Leave a Reply

Your email address will not be published. Required fields are marked *