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

来源:爱站网时间:2021-09-23编辑:网友分享
我的Jooq查询:dslContext.select(timeInterval,ifnull(avg(field(FieldName.AVERAGE,Double.class)).cast(Double.class),0.0))....

问题描述


我的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));

返回附加了时区和双精度的时间戳

但是我的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" 

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

思路:


SQL类型TIMESTAMP WITHOUT TIME ZONE(或仅TIMESTAMP)的默认JDBC类型是java.sql.Timestamp。出于历史原因,我们都感到遗憾,java.sql.Timestamp扩展了java.util.Date,该模型通过将您的[[JVM

上一篇:如何在Java中有效地计算此计算?

下一篇:这为什么会产生StackOverflowError

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载