diff --git a/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java b/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java index 3ae9463ea4..3f80eff0c7 100644 --- a/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java +++ b/sql-jdbc/src/main/java/org/opensearch/jdbc/types/TimestampType.java @@ -8,6 +8,7 @@ import java.sql.SQLException; import java.sql.Timestamp; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Calendar; import java.util.Map; @@ -78,13 +79,17 @@ else if (value.charAt(23) == '+' || value.charAt(23) == '-') { } } - if (calendar == null) { - return Timestamp.valueOf(value); + final Timestamp ts; + if (value.length() < 11) { + ts = Timestamp.valueOf(LocalDate.parse(value).atStartOfDay()); } else { - Timestamp ts = Timestamp.valueOf(value); - return localDateTimeToTimestamp(ts.toLocalDateTime(), calendar); + ts = Timestamp.valueOf(value); } + if (calendar == null) { + return ts; + } + return localDateTimeToTimestamp(ts.toLocalDateTime(), calendar); } catch (IllegalArgumentException iae) { throw stringConversionException(value, iae); }