• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Convert a String with a date valus for Oracle

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I take a date entered into a text field and add it to the database as a date format so I can query it.

e.g. (European) 12/01/2005

what API's are available for Oracle to format from a String to a proper date format?

If some one has code example.

Reg
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reggie,
As requested. Note, however, that the below code is uncompiled, and untested.
It is also not really complete. It is intended only as a guide -- to get you started (with your homework assignment?)

Good Luck,
Avi.
 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the jdbc interface all you need to pass is the java object for date or timestamp whichever is applicable. If you are passing a string to an oracle procedure or function that depends on the NLS_DATE_FORMAT database parameter. This can be modified for a session using the ALTER SESSION command.
 
Reggie McDougal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, thanks what I needed to know

Reg
 
Reggie McDougal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works fine, rather than use the API the oracle format is simpler
is there any disadvantage to this method?

Reg



[edited to add line breaks so page doesn't scroll right]
[ January 19, 2005: Message edited by: Jeanne Boyarsky ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. By parsing your date string in SQL, you tie your JDBC code to Oracle, rather than leaving it database independant as it would be if you parsed the date in your Java code. Also you tie your date parsing to one Locale. By convention dates are described differently depending on where you are in the world (for example, typically Americans put the month before the day, while the British put the day before the month). If you parse your date in Java you can swap the formatting rules depending on Locale, but you can't do this in SQL.
[ January 19, 2005: Message edited by: Paul Sturrock ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic