I am having a database in firebird. There is a field DAT_OF_BIRTH in a table, its type is TIMESTAMP (which can properly maps over java.sql.Date).
But the problem is this that in this db's field accept date in format of yyyy-mm-dd. While my user interface sends in dd-mm-yyyy. On middle tier Iv tried to use java.text.Dateformat but still its not working.
Could you please tell me a way to change representation of Date.
Regards,<br /> <br />Ahsan Jamil<br />SCJP, SCWCD, IBM OOAD
No, you don't. Databases do not store dates as Strings.
Presuming your front end is allowing users to input dates in this format: dd-MM-yyyy, then you need to add something to parse these strings there (have a look at java.text.SimpleDateFormat). Once you've parsed it, you can pass it about as a Date object. 10-01-2003, 2003-01-01, 1st Jan 2003, 01-Jan-2003, 1/1/2003 etc. are all different presentations of the Date value 1041379200000. When you bind this Object to a PreparedStatement it is the value not the format which is bound.