tags:

views:

1327

answers:

2

I have a table with an oracle date column

when I do a select on sqlplus on the column it gives me the value like this

10-JAN-2007
  1. Is this the precision of date in an Oracle column i,e does it not have hour sec, millisec in the date column.
  2. How can I map this to a java timestamp and get seconds since epoch.
+3  A: 

If you select it using java.sql Statement/PreparedStatement, it will return a java.sql.Date, which you can then do a .getTime() on just like a regular java.util.Date.

Depending on the RDBMS, if you really want a timestamp, though, you have to make the column a timestamp type and select it into a java.sql.Timestamp. Otherwise it will give you the time of 12am.

Paul Tomblin
+3  A: 

No, the Oracle DATE column does store hours, minutes and seconds. However, sqlplus will only show month, day, year by default. Use the following before running your query to show the full date and time:

alter session set NLS_DATE_FORMAT='DD-MM-YYYY HH24:MI:SS';

The difference between the DATE and TIMESTAMP column types in Oracle is that TIMESTAMP will store fractional seconds.

Chris Thornhill