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.Dateis meant to store only date without time information.You should use
java.sql.Timestamp,setTimestampandgetTimestampto handle date & time informations.Look also at
java.sql.Timeandset/getTimeif you need only time information.