getDateTime from ResultSet java

Luc picture Luc · Apr 3, 2013 · Viewed 36.4k times · Source

I have two columns which store DateTime values in a MySql database,

When I try to get them from a ResultSet in Java there is no option: getDateTime()

Should I use getDate() or wouldn't that work?

Thanks in advance

Answer

tmwanik picture tmwanik · Apr 3, 2013

Using getDate() only returns a Date, so in your case if you want both date and time use getTimestamp(String columnLabel) - That should work, also replace String columnLabel with the actual column name in the database.