Answer the question
In order to leave comments, you need to log in
How to get date from database?
From the database I get a string with the date and time.
The string could be: 2015-01-25 16:26:08.34
ResultSet rs;
java.sql.Timestamp sqlts = rs.getTimestamp(index);
Then this date should be used in an external object (processing, sorting, etc.)
What and how to convert it better util.Date or util.Calendar?
Answer the question
In order to leave comments, you need to log in
Timestamp is a normal long.
Try this new Date(sqlts.getTime()).
In Java 8, Timestamp has toInstant() and toLocalDateTim() methods. You can try to use them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question