My data is in format:
2010-12-01 09:59:00.423
getDate in Java only returns the date portion. 开发者_开发技巧Is there a way to also extract the time?
The SQL DATE
type indeed only contains the date portion, not the time. But your column is apparently of TIMESTAMP
type, so to get the full timestamp, use ResultSet#getTimestamp()
instead.
Date date = resultSet.getTimestamp("columnname");
// ...
It returns java.sql.Timestamp
which is a subclass of java.util.Date
, so the upcast is safe.
精彩评论