Skip to content

Commit

Permalink
Merge pull request #3567 from ingef/fix/localdate-cast
Browse files Browse the repository at this point in the history
fix casting date to integer not long
  • Loading branch information
awildturtok authored Sep 19, 2024
2 parents 081358a + d760e58 commit d6d6352
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ public Boolean getBoolean(ResultSet resultSet, int columnIndex) throws SQLExcept
}

@Override
public Number getDate(ResultSet resultSet, int columnIndex) throws SQLException {
public Integer getDate(ResultSet resultSet, int columnIndex) throws SQLException {
String dateString = resultSet.getString(columnIndex);
if (dateString == null) {
return null;
}
DateReader dateReader = config.getLocale().getDateReader();
return dateReader.parseToLocalDate(dateString).toEpochDay();
return (int) dateReader.parseToLocalDate(dateString).toEpochDay();
}

@Override
Expand Down Expand Up @@ -129,6 +129,7 @@ private interface Getter {
* For example, calling a primitives' ResultSet getter like getDouble, getInt etc. straightaway will never return null.
*/
private static <T> T checkForNullElseGet(ResultSet resultSet, int columnIndex, Getter getter, Class<T> resultType) throws SQLException {

if (resultSet.getObject(columnIndex) == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface ResultSetProcessor {

Boolean getBoolean(ResultSet resultSet, int columnIndex) throws SQLException;

Number getDate(ResultSet resultSet, int columnIndex) throws SQLException;
Integer getDate(ResultSet resultSet, int columnIndex) throws SQLException;

List<Integer> getDateRange(ResultSet resultSet, int columnIndex) throws SQLException;

Expand Down

0 comments on commit d6d6352

Please sign in to comment.