一、Druid默认时区
默认使用UTC+0000,数据存储的时间timeStamp为UTC+0000
二、北京时间
在中国,使用UTC+0800,查询时间需要设置时区或者将时区转换为UTC+0000时间
以下查询是UTC+0000时间,查询结果的dateTime也是UTC+0000时间需要进行时区转换
select "__time", "value"
from access_log
where "__time">=TIMESTAMP '2019-12-06 06:12:00' and "__time"<=TIMESTAMP '2019-12-07 06:12:00'
三、解决方案
所有日期转为long类型,就不会存在时区错乱的问题
select TIMESTAMP_TO_MILLIS("__time") "__time","value"
from "access_log"
where "__time">=MILLIS_TO_TIMESTAMP(1576259650000) and "__time"<=MILLIS_TO_TIMESTAMP(1576302850000)