hubble时区设置 为客户端session级别设置
SHOW TIME ZONE;
root@poc-hubble01:35432/defaultdb> SHOW TIME ZONE;
timezone
-----------------
Asia/Shanghai
(1 row)
select now();
root@poc-hubble01:35432/defaultdb> select now();
now
---------------------------------
2022-03-21 13:50:22.843663+08
(1 row)
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
public static void main(String[] args) {
// TODO Auto-generated method stub
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
try {
Class.forName('org.postgresql.Driver');
Connection con = DriverManager.getConnection(url, user, password);
} catch (Exception e) {
// TODO: handle exception
}
}
-Duser.timezone=Asia/Shanghai
-Duser.timezone=Asia/Shanghai
-Dosgi.requiredJavaVersion=11
-Xms64m
-Xmx1024m
-Ddbeaver.distribution.type=exe
-Duser.timezone=Asia/Shanghai
set timezone='Asia/Shanghai';
root-hubble01:35432/defaultdb> set timezone='Asia/Shanghai';
SET
Time: 0ms total (execution 0ms / network 0ms)
将当前时间返回前台
调整时区后,截取当前的时间,返回给前台,若不进行时区调整将会有时间差 用now()函数返回给当前时间的时候,要引用当前时区(比如:shanghai)
root@poc-hubble01:15432/defaultdb> select to_char((now() :: timestamp without time zone),'%Y-%m-%d %H:%M');
to_char
+------------------+
2022-04-26 07:34
(1 row)
root@poc-hubble01:15432/defaultdb> select to_char((now() :: timestamp without time zone),'%Y-%m-%d %H:%M');
to_char
+------------------+
2022-04-26 15:35
(1 row)
Time: 449.134µs