…n the text path
A LocalDateTime bound via setObject on the text path was converted to an instant
using the JVM default time zone, so the stored value depended on the JVM's zone.
A LocalDateTime has no instant; its fields should be interpreted in the column or
server time zone, like Timestamp and a string literal already are.
encodeObject now renders a LocalDateTime as a quoted wall-clock string instead of
fromUnixTimestamp64Nano(..., JVM zone). The old JVM-zone behaviour is available via
the new jdbc_legacy_localdatetime_jvm_timezone property (default false).
Fixes #3127
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
A
LocalDateTimebound throughPreparedStatement.setObjecton the text path was converted to an instant using the JVM default time zone, so the stored value depended on the time zone of the JVM running the application. ALocalDateTimehas no instant, so its fields should be interpreted in the column's time zone, or the server time zone when the column has none, with the JVM zone playing no part (this matchesTimestamp, a string literal, and the reader).Fixes #3127.
Behaviour change (semver note)
On a non-UTC JVM this changes the stored value for
setObject(LocalDateTime)on the text path so it matchesTimestamp, a string literal, and the reader. This is the stable text path, so the previous behaviour is available with a new opt-out property:jdbc_legacy_localdatetime_jvm_timezone=true.Fix
encodeObjectnow renders aLocalDateTimeas a quoted wall-clock string, exactly as aTimestampalready is, instead offromUnixTimestamp64Nano(..., JVM zone). The server then interprets it in the column/server zone. The legacy JVM-zone path is kept behind the new property.Testing
setObject(LocalDateTime)stores the same value as the equivalent string literal, forDateTimeandDateTime64.LocalDateTimevsTimestampequal (server zone, no JVM shift), and the opt-out restores the JVM-shifted value. 89 assertions per run, 0 failures.🤖 Generated with Claude Code
Note
Medium Risk
Changes how datetime parameters are serialized for writes, which can shift stored values on non-UTC JVMs unless the legacy property is enabled.
Overview
PreparedStatement.setObject(LocalDateTime)on the text path no longer converts through the JVM default time zone viafromUnixTimestamp64Nano(...). It now emits a quoted wall-clock string (same asTimestamp), so ClickHouse interprets it in the column/server time zone—matching string literals and the reader.This is a behavior change on non-UTC JVMs. The old path is preserved behind
jdbc_legacy_localdatetime_jvm_timezone=true(DriverProperties.LEGACY_LOCALDATETIME_JVM_TIMEZONE).Adds a changelog note in
history/latest/3127.mdand an integration test ensuringLocalDateTimeinserts match equivalent string literals forDateTimeandDateTime64.Reviewed by Cursor Bugbot for commit f2385cd. Bugbot is set up for automated code reviews on this repo. Configure here.