File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping Java Date to an Oracle Date.

 
Tony Evans
Ranch Hand
Posts: 597
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get todays date from my java application and add it to my Oracle Database.
I need to add the date in the format '31-OCT-02'
the only string in this format is using the date method toGMTString() toGMTString()
'31-OCT-2002 14:41:24 GMT'
I can parse this string to translate it into the Oracle format, but I wonder is there a more efficient manner.
Cheers for any help Tony
 
Tony Evans
Ranch Hand
Posts: 597
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also how do I add 5 days to a date, I have looked at the Date Class, and i cannot see any methods that will allow me to do this.
Cheers Tony
 
Tony Evans
Ranch Hand
Posts: 597
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Worked out the solution to the second problem.
Calendar c = new GregorianCalendar();
Date d = c.getTime();
System.out.println("CreateCustomerOrder : service() : ToDays Date "+d.toGMTString());
c.add(Calendar.DATE,5);
d = c.getTime();
System.out.println("CreateCustomerOrder : service() : Future Date "+d.toGMTString());

System.out.println("CreateCustomerOrder : service() : Get CustomerOrderID");
Tony
 
prabhat kumar
Ranch Hand
Posts: 114
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for converting to sql.Date type
 
Leslie Chaim
Ranch Hand
Posts: 336
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would give the work to Oracle
First of all, in Oracle if you insert into a DATE column, and your date literal is in the default data format (which is usually DD-MON-YY) then you can simply send the string to Oracle like this:

Second, you can use Oracle's to_date function:

Yes the above is a bit crazy with the YYDDMM, but the point is made
Third, to add 5 days why not give it to Oracle?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic