• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mapping Java Date to an Oracle Date.

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for converting to sql.Date type
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic