我有一个内部连接表的查询:
List<Object[]> resultList = entityManager.createNativeQuery(SOME QUERY).getResultList();
当我尝试访问Object[]
其中一个元素时,Date
我尝试这样做:
for(Object[] obj : resultList) {
Date createdDate = obj[7] !=null ? new Date(Long.valueOf(obj[7] + "")) : null;
}
这给出了明显的例外:
nested exception is java.lang.NumberFormatException: For input string: "2012-11-20"
我改变Date
了DateTime
得到TO_CHAR(createdDate,'DD.MM.YYYY:HH24:MI:SS')
并尝试了以下代码:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date createdDate = null;
try {
createdDate = df.parse(obj[7] + "");
} catch (ParseException e) {
e.printStackTrace();
}
这种方法的结果:createdDate = null
有什么建议么 ?