Search code examples
javamysqldatetimeresultset

getDateTime from ResultSet java


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


Solution

  • 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.