Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing dates using prepared statements

 
prav ba
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
have got a method which converts java.util.Date to java.sql.Date and stores it to oracle 11g db.




the problem is that when i look into the db the value stored is 05-05-0005 which is not correct since i would have thought the value stored would be 05-05-2005.

can anyone explain why this is happening ??

thanks.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is nothing to do with JDBC at all. You simply have misunderstood SimpleDateFormat. Direct quote from its API documentation:
For parsing, if the number of pattern letters is more than 2, the year is interpreted literally, regardless of the number of digits. So using the pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
 
prav ba
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aha !! thanks Paul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic