aspose file tools*
The moose likes Java in General and the fly likes DB2 Date format to Oracle Date format? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "DB2 Date format to Oracle Date format?" Watch "DB2 Date format to Oracle Date format?" New topic
Author

DB2 Date format to Oracle Date format?

Sam Drake
Ranch Hand

Joined: Jun 05, 2003
Posts: 33
Hi,
I need to convert a DB2 date (or timestamp) to Oracle format (MM/dd/yyyy).
Please suggest the easiest method.
Thnx,
Sam.
John Ipe
Greenhorn

Joined: Dec 29, 2003
Posts: 25
Hi,
What is the format for the DB2 date? Have you tried using java.text.SimpleDateFormat?
Regards
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
I thought the default Oracle format was DD-MON-YYYY, as in '06-JAN-2004'. I think that's the way dates come out in DB2 also. Actually, I think that is some kind of standard.
Anyway, if you have a string in a particular format, you can convert in Oracle using the TO_DATE and TO_CHAR functions.
For example, if you have a string that looks like '06-JAN-2004', and you want to display a string that looks like '01/06/04', you could
1) Convert the string to a Date with TO_DATE( string, 'DD-MON-YYYY')
2) Convert the Date back to a string with TO_CHAR( date, 'MM/DD/YY')
Putting it all together, it looks like this:
Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
I agree with John, use the method format, in class java.text.SimpleDateFormat to format de java.sql.Date object that you extract from ResultSet.


Gustavo Adolpho Bonesso<br />SCJP1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB2 Date format to Oracle Date format?