Java日期休眠中断时间 [英] Java Date Hibernate cut off time
问题描述
我在Oracle DB中有一个日期类型列,它确实包含日期和时间。但是当我试图在java应用程序中获取数据时,它将返回一堆零而不是实时的日期。
在代码中,它会是这样的:
$ SQL $ sqlQuery = session.createSQLQuery(SELECT table.id,table .date FROM table);
List< Object []> resultArray = sqlQuery.list();
日期日期=(日期)resultArray [1];
如果是DB-26-feb-2010 17:59:16我会得到26- feb-2010 00:00:00
如何获得它?
我不是专家Oracle,但您可能需要一个 DateTime
列类型来获得时间戳。
有了这个需要使用 java.sql.Timestamp
JDBC类型。
I have a Date type column in Oracle DB and it contains date and time for sure. But when I'm trying to get data in java application it will return date with bunch of zeros instead of real time. In code it'll be like:
SQLQuery sqlQuery = session.createSQLQuery("SELECT table.id, table.date FROM table");
List<Object[]> resultArray = sqlQuery.list();
Date date = (Date)resultArray[1];
If it was 26-feb-2010 17:59:16 in DB I'll get 26-feb-2010 00:00:00 How to get it with time?
I am not an expert with Oracle, but you probably need a DateTime
column type to get a time stamp.
With that you need to use java.sql.Timestamp
JDBC type.
这篇关于Java日期休眠中断时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!