Last active
December 27, 2015 09:19
-
-
Save oehme/7303563 to your computer and use it in GitHub Desktop.
Joda Time to JDBC - fails on DST transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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