• 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

Date format

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get my current date for PreparedStatement Oracle 9i insert like this:


I then use this for my insert setter:

Is there someway to format the entry that goes in the database?
It currently inputs this in the database: 2008-10-15 11:23:00.807
I would like this instead: 15-Oct-08 11:23:00 PM
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nick,
What data type do you have in the database? If it is Date/Timestamp (or your database equivalent), it is not stored in any format. When you query the column you would specify the format.

If it is stored as a varchar, you would want to use SimpleDateFormat to set your format. Then call stmt.setString() to use that format.

Needless to say, using a Date/Timestamp type in the database is recommended.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to move this to our JDBC forum since it's more about database interaction.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You dont have any control over the format the Timestamp is kept in the database. You can set the date time to what ever you want when you put it in of course . You can also control how you want to format it when you get a timestamp out of the database and display or print it somewhere.
 
reply
    Bookmark Topic Watch Topic
  • New Topic