如何从“无时区的时间戳”字段收集到无时区的Java时间戳

问题描述 投票:0回答:1

我的Jooq查询:

dslContext.select(
                timeInterval,
                ifnull(avg(field(FieldName.AVERAGE, Double.class))
                        .cast(Double.class), 0.0))
                .from(channelTimebucketQuery)
                .groupBy(timeInterval)
                .orderBy(timeInterval)
                .collect(Collectors.toMap(Record2::component1, Record2::component2));

返回附加了时区和双精度的时间戳enter image description here

但是我的Profiler说它应该返回一个没有时区的时间戳。

select pg_typeof(time_bucket) from (

    select "alias_67258973"."time_bucket", coalesce(cast(avg(average) as double precision), 0.0) from (select "public"."time_bucket_gapfill"("bucket_width" := cast("public"."create_interval"("seconds" := 43200) as "pg_catalog"."interval"), "ts" := cast("public"."testTable"."time" as timestamp), "start" := cast(null as timestamp), "finish" := cast(null as timestamp)) as "time_bucket", avg("public"."testTable"."average") as "average" from "testTable" where ("public"."testTable"."device" in ('702088'  ) and "public"."testTable"."time" >= timestamp '2020-02-10 13:57:28.2212375' and "public"."testTable"."time" <= timestamp '2020-02-24 13:57:28.2222399') group by time_bucket) as "alias_67258973" group by "alias_67258973"."time_bucket" order by "alias_67258973"."time_bucket"
        ) as x;

enter image description here

时区来自哪里?我如何将时区设置为+ 0000

java psql jooq timezone-offset
1个回答
0
投票
SQL类型TIMESTAMP WITHOUT TIME ZONE(或仅TIMESTAMP)的默认JDBC类型是java.sql.Timestamp。出于历史原因,我们都感到遗憾,java.sql.Timestamp扩展了java.util.Date,该模型通过将您的[[JVM
© www.soinside.com 2019 - 2024. All rights reserved.