File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 Date format to Oracle Date format?

 
Sam Drake
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the format for the DB2 date? Have you tried using java.text.SimpleDateFormat?
Regards
 
Michael Zalewski
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic