I call stored function with such signature:
FUNCTION ADDDAYS (city VARCHAR2, startDate DATE, numDays INTEGER)
开发者_运维技巧
from java code:
        JdbcTemplate jt = getJdbcTemplate();
        Object o = jt.execute("{? = call ADDDAYS(?, ?, ?)}", new CallableStatementCallback() {
            public Object doInCallableStatement(CallableStatement stmt) throws SQLException, DataAccessException {
                 stmt.registerOutParameter(1, Types.DATE);
                stmt.setString(2, city);
                stmt.setDate(3, new java.sql.Date(startDate.getTime()));
                stmt.setInt(4, daysNum);
                stmt.execute();
                return new Date(stmt.getDate(1).getTime());
            }
        });
when I pass startDate with time return value contais 00:00 as time (stored procedure doesn't cut time part, i checked it with direct calls from sql editor). So looks like time part is removed in sending to/receiving form Oracle. is it possible to fix it? Thanks.
java.sql.Date is meant to store only date without time information.
You should use java.sql.Timestamp, setTimestamp and getTimestamp to handle date & time informations.
Look also at java.sql.Time and set/getTime if you need only time information.
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
 加载中,请稍侯......
      
精彩评论