Im公司正在开发一个P Spring Boot应用程序,查询邮政总局的数据库。
页: 1 我的申请的最终使用者希望自己在时间区看到这些时间点,但所抵消之处包括。 例如,
Given 载有<编码>2023-08-10T12:00:00.000+00的行文
When the user queries from time zone US/Eastern
Then the output they should see is 2023-08-10T08:00:00.000-04
Sounds simple enough, but I m having trouble figuring out how to handle this given that there will be multiple concurrent requests coming from different time zones.
如果我是在科索尔执行,它给我
SET LOCAL TIME ZONE US/Eastern ;
SELECT to_char( 2023-08-10T12:00:00.000+00 ::TIMESTAMPTZ, YYYY-MM-DD"T"HH24:MI:SS.MSOF );
2023-08-10T08:00:00.000000-04
然而,我不知道如何在我的春天布道申请中利用这一点。
- According to my benchmarks, if I try to do this in code, it comes with a ~30% performance penalty, which is significant in this case, so I would like to do it entirely in SQL if possible.
- I cannot execute two separate statements separated by
;
in aPreparedStatement
- I do not want to change the default time zone for the database, since there may be multiple concurrent requests.
- For the same reason, I do not want to change the default time zone for the JVM.
因此,回答其中任何一个问题都会大大有助于:
- In jdbc, is there a way to set the time zone for only a single query, without affecting other concurrent queries?
- In PostgreSQL, is there a way I can express the above SQL in a single line (no semi colons)?