I am querying data from a database and want to convert a Database Timestamp to a java.sql.Timestamp:
List<Map<String, Object>> rows = jdbcTemplate.queryForList(SELECT_ALL_DATA);
for(Map row : rows) {
Customer customer = new Customer();
customer.setMaturityDate(new Timestamp((Long) row.get("MATURTIY_DATE")));
}
However, doing it like that gives me:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.lang.Long
I also tried it without the cast to Long, but this gives me:
The constructor Timestamp(Object) is undefined
Any recommendations how to cast the database object?
I appreciate your reply!