• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date format

 
Nick Davenport
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34863
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 34863
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to our JDBC forum since it's more about database interaction.
 
Agador Paloi
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic