Skip to content

Commit be52a87

Browse files
author
Paultagoras
committed
Update JdbcUtils.java
1 parent 6d30ed9 commit be52a87

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import com.clickhouse.data.ClickHouseDataType;
44

5+
import java.sql.Date;
56
import java.sql.JDBCType;
67
import java.sql.SQLException;
78
import java.sql.SQLType;
89
import java.time.LocalDate;
910
import java.time.LocalDateTime;
11+
import java.time.LocalTime;
1012
import java.time.OffsetDateTime;
1113
import java.time.ZonedDateTime;
1214
import java.time.temporal.TemporalAccessor;
@@ -163,6 +165,12 @@ public static Object convert(Object value, Class<?> type) throws SQLException {
163165
return OffsetDateTime.from((TemporalAccessor) value);
164166
} else if (type == ZonedDateTime.class && value instanceof TemporalAccessor) {
165167
return ZonedDateTime.from((TemporalAccessor) value);
168+
} else if (type == Date.class && value instanceof TemporalAccessor) {
169+
return Date.valueOf(LocalDate.from((TemporalAccessor) value));
170+
} else if (type == java.sql.Timestamp.class && value instanceof TemporalAccessor) {
171+
return java.sql.Timestamp.valueOf(LocalDateTime.from((TemporalAccessor) value));
172+
} else if (type == java.sql.Time.class && value instanceof TemporalAccessor) {
173+
return java.sql.Time.valueOf(LocalTime.from((TemporalAccessor) value));
166174
}
167175
} catch (Exception e) {
168176
throw new SQLException("Failed to convert " + value + " to " + type.getName(), ExceptionUtils.SQL_STATE_DATA_EXCEPTION);

0 commit comments

Comments
 (0)