JdbcTemplate batch update in postgresql - date loses time?
-
22-09-2019 - |
Question
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.
Solution
Use java.sql.Timestamp instead. And by the way, your posted snippets barely giving us any hint.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow