Skip to content

Commit

Permalink
Added base Calendar implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
alex268 committed Jul 30, 2024
1 parent 914b648 commit 0028cdb
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions jdbc/src/main/java/tech/ydb/jdbc/impl/YdbResultSetImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,13 @@ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
if (instant == null) {
return null;
}
final TimeZone tz = cal != null ? cal.getTimeZone() : Calendar.getInstance().getTimeZone();
return Date.valueOf(instant.atZone(tz.toZoneId()).toLocalDate());

if (state.description.isTimestamp()) {
final TimeZone tz = cal != null ? cal.getTimeZone() : Calendar.getInstance().getTimeZone();
return Date.valueOf(instant.atZone(tz.toZoneId()).toLocalDate());
}

return Date.valueOf(instant.atOffset(ZoneOffset.UTC).toLocalDate());
}

@Override
Expand All @@ -478,8 +483,13 @@ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
if (instant == null) {
return null;
}
final TimeZone tz = cal != null ? cal.getTimeZone() : Calendar.getInstance().getTimeZone();
return Time.valueOf(instant.atZone(tz.toZoneId()).toLocalTime());

if (state.description.isTimestamp()) {
final TimeZone tz = cal != null ? cal.getTimeZone() : Calendar.getInstance().getTimeZone();
return Time.valueOf(instant.atZone(tz.toZoneId()).toLocalTime());
}

return Time.valueOf(instant.atOffset(ZoneOffset.UTC).toLocalTime());
}

@Override
Expand All @@ -493,8 +503,13 @@ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
if (instant == null) {
return null;
}
final TimeZone tz = cal != null ? cal.getTimeZone() : Calendar.getInstance().getTimeZone();
return Timestamp.valueOf(instant.atZone(tz.toZoneId()).toLocalDateTime());

if (state.description.isTimestamp()) {
final TimeZone tz = cal != null ? cal.getTimeZone() : Calendar.getInstance().getTimeZone();
return Timestamp.valueOf(instant.atZone(tz.toZoneId()).toLocalDateTime());
}

return Timestamp.valueOf(instant.atOffset(ZoneOffset.UTC).toLocalDateTime());
}

@Override
Expand Down

0 comments on commit 0028cdb

Please sign in to comment.