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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top