【发布时间】:2014-10-23 06:47:48
【问题描述】:
我正在从数据库中查询数据,并希望将数据库时间戳转换为 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")));
}
但是,这样做会给我:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.lang.Long
我也尝试过不使用 Long 的演员表,但这给了我:
The constructor Timestamp(Object) is undefined
关于如何转换数据库对象有什么建议吗?
感谢您的回复!
【问题讨论】: