1

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.

2
  • I hope you realizing that an ADDDAYS function is reinventing the wheel; adding an number to an Oracle DATE or TIMESTAMP adds that number of days (or fractions thereof) to it. Commented Apr 15, 2010 at 19:57
  • It is not just adding of N days to specified date, it uses business days calendars for different cities. Why whould I pass city parameter to this function if I just need to add N days to current date. Commented Apr 16, 2010 at 9:13

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.