views:

302

answers:

5

I am inserting a record to orcle db through java application. The date value inserted as 02/10/0010 instead of 02/10/2010 HH:MM:SS AM/PM? I am using oracle jdbc connection. Does it problem with JDBC driver ? Any input on this.

+1  A: 

Check your date source. Is it two digit year or four?

Also, there are Oracle date mask formats which might cause that. Check the default for the installation.

wallyk
A: 

I'm guessing that the value you're passing in is "02/10/10".

Date functions are pretty inconsistent about what they do with 2 digit years. If you are trying to enter dates for your "timeline of ancient history", having the computer assume that 2-digit dates must be shorthand for the 21st century would be very annoying. We really are better off with a WYSIWYG date interpretation.

Jay
+2  A: 

If you're using Oracle and JDBC, don't store Date in your table as a String. Make it a real Date and you'll spare yourself all this pain.

duffymo
A: 

Agree.

If you use a Java Date format (dunno its class just now) then JDBC driver performs all what is needed to store it in a Date column.

If you use String in java and/or varchar2 in Oracle table, you are doing it wrong. This will lead to implicit conversions, NLS settings and all that pain... if you are in this bad shape then you need explicit conversions and format masks on each date usage.

Use proper types.

Josep
A: 

Jithesh : To_date(to_date(expr)) will give year in 0010

jithesh