set time java oracle.

B

bigbinc

I am using this to get the current date.
java.sql.Date sqlDate01 = new java.sql.Date(System.currentTimeMillis());

java.sql.Time _sqlTime = new java.sql.Time(System.currentTimeMillis());

"to_date('" + "" + sqlDate01 + "','YYYY/MM/DD'),"

How do I get the time in Oracle 9.2 using the jdbc driver.

My oracle field is set to 'DATE' even though I want to set the time.
 
B

Bjorn Abelli

...
I am using this to get the current date.

I'm not sure what you really want to do.

Do you want to *get* the system-time from
the oracle server, or do you want to *set*
the system-time on the oracle server?
How do I get the time in Oracle 9.2
using the jdbc driver.

In the same way you get the date...
My oracle field is set to 'DATE' even
though I want to set the time.

In Oracle the DATE includes the time as well, just as a Date in Java does.

Example getting Oracle's special DATE-type:

oracle.sql.DATE oracleDate =
((OracleResultSet)rset).getDATE (1);

java.sql.Time sqlTime =
oracleDate.timeValue();

....but it also works well without the need of casting to Oracle-specific
things, by using the usual Time- or Timestamp-method

java.sql.Time sqlTime = rset.getTime (1);
java.sql.Timestamp sqlTimestamp = rset.getTimestamp (1);

Since both Time and Timestamp has inherited from java.util.Date, the rest
should be straightforward...

// Bjorn A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top