Skip to content

Instantly share code, notes, and snippets.

@oehme
Last active December 27, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oehme/7303563 to your computer and use it in GitHub Desktop.
Save oehme/7303563 to your computer and use it in GitHub Desktop.
Joda Time to JDBC - fails on DST transition
public LocalDateTime getValue(ResultSet rs, int index) throws SQLException {
Timestamp ts = rs.getTimestamp(index);
return ts != null ? new LocalDateTime(ts.getTime()) : null;
}
public void setValue(PreparedStatement st, int index, LocalDateTime value) throws SQLException {
DateTime dt = value.toDateTime(); //uses defaul timezone
st.setTimestamp(index, new Timestamp(dt.getMillis())); //uses default timezone
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment