Wednesday, December 5, 2012

Insert UTC date in Oracle database with Java and Spring

Neither java.util.Date nor Oracle Date stores timezone information. In your case Jdbc driver converts your date using the JVM timezone. You can use one of the following options:
  • If you are using PreparedStatement, you can use setDate(int parameterIndex, Date x, Calendar cal) method to specify Calendar in UTC timezone.
  • For Spring jdbcTemplate instead of inserting Date object, insert Calendar with UTC timezone
  • TimeZone.setDefault(TimeZone.getTimeZone("GMT")) could be set on JVM lvl
  • Use -Duser.timezone=GMT on JVM startup
http://stackoverflow.com/questions/12563553/insert-utc-date-in-oracle-database-with-java-and-spring

No comments:

Post a Comment