File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Oracle/OAS and the fly likes datefiled in dd-mm-yyyy format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "datefiled in dd-mm-yyyy format " Watch "datefiled in dd-mm-yyyy format " New topic
Author

datefiled in dd-mm-yyyy format

indu iyengar
Ranch Hand

Joined: Jul 30, 2010
Posts: 115
Hi

how to create a table with field DOB in dd-mm-yyyy format?

so that I can insert date in dd-mm-yyyy format .

thanks
indu


thanks ,
Indu
Agador Paloi
Ranch Hand

Joined: Jan 24, 2006
Posts: 118
I always use date or timestamp for a date - time table column.
To define your table would be something like this:

To put in a row would be :


you use a mask in your to_date function of your sql to determine the date format you want.
indu iyengar
Ranch Hand

Joined: Jul 30, 2010
Posts: 115

inserting finely .. but when I retrieve

the result is in yyyy-mm-yy format .
thanks
indu
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

A DATE field in a DB only 'holds' the date, in no specific format - you need to use DateFormat (SimpleDateFormat) to format your date to what you want afterwards.


Regards, Rene Larsen
Dropbox Invite
Agador Paloi
Ranch Hand

Joined: Jan 24, 2006
Posts: 118
or you can use a mask in your select



Agad
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Oracle stores all DATE data types as a seven digit binary. The format mask you use on insert statement has nothing to do with how it is stored.

As Agador correctly states, you use to_char to convert your date to a string and choose your format mask for display.

If you don't explicitly do this yourself, Oracle will internally call a version of to_char to convert the binary data to a string using the default date format parameter stored in the nls_database_parameter table. Usually this is dd-mon-rr by default.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: datefiled in dd-mm-yyyy format
 
Similar Threads
How to fetch Date Field from excel sheet in Java
conversion of date
Time stamp format
java.sql.Date
java.text.ParseException