views:

348

answers:

2

I am inserting a list of object with java.util.date in format YYYY-MM-DDThh:mm:ssTZD (2008-09-26T14:34:59+02:00).

SQL:

INSERT INTO cdate (key,valuedate,user_id) VALUES(?,?,?)

BatchPreparedStatementSetter bpss = new MetaJdbc().setMetaBatchPreparedStatement(
        list, userId);
getJdbcTemplate().batchUpdate(sql,bpss);

Date is in right format, but in PostgreSQL it saves only just like that: "2008-09-26 00:00:00+02"

Edit: I was in a hurry before... I did not give enough info, sorry.

A: 

What is the type of the field in the database? Is it date or datetime?

Also, what is this MetaJdbc class? It may put the wrong type (DATE instead of TIMESTAMP)

David Rabinowitz
Type was ok. Vinegar cleared my mind :)
Trick
+1  A: 

Use java.sql.Timestamp instead. And by the way, your posted snippets barely giving us any hint.

Adeel Ansari
I added edit. But even so, you got it :) I totally forgot and use java.sql.Date
Trick
But now its working. . . and thats the cool part. :)
Adeel Ansari