aspose file tools*
The moose likes JDBC and the fly likes Mapping Java Date to an Oracle Date. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Mapping Java Date to an Oracle Date." Watch "Mapping Java Date to an Oracle Date." New topic
Author

Mapping Java Date to an Oracle Date.

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 582
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

Joined: Jun 29, 2002
Posts: 582
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

Joined: Jun 29, 2002
Posts: 582
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

Joined: Apr 11, 2001
Posts: 114
for converting to sql.Date type
Leslie Chaim
Ranch Hand

Joined: May 22, 2002
Posts: 336
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?


Normal is in the eye of the beholder
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mapping Java Date to an Oracle Date.