ITADN

Timestamp column not retrieving values in UTC time zone

#2431Closedrihi 创建于 2025-02-25
R
rihicommented
I believe the recent pull request https://github.com/JetBrains/Exposed/pull/2386 tried to fix the behavior of timestamp columns (`KotlinInstantColumnType`, `JavaInstantColumnType`) to always store values in UTC. However, on my system with SQLite, retrieving timestamps from a database results in the UTC timestamps being interpreted as if they were in my system local time zone. I believe the cause to be the following lines of code: https://github.com/JetBrains/Exposed/blob/a17743d6a823b82a2a4e2a02cf1526f967fc3249/exposed-kotlin-datetime/src/main/kotlin/org/jetbrains/exposed/sql/kotlin/datetime/KotlinDateColumnType.kt#L393-L395 https://github.com/JetBrains/Exposed/blob/a17743d6a823b82a2a4e2a02cf1526f967fc3249/exposed-java-time/src/main/kotlin/org/jetbrains/exposed/sql/javatime/JavaDateColumnType.kt#L377-L379 This uses `ResultSet#getTimestamp(index)`, which yields timestamp objects which are in the system local time zone if no calendar object is explicitly passed.
关闭于 2025-02-26 1 条评论