我解决Jackson时间戳转换为LocalDateTime,好不容易解决了报错,但是却发现控制台中输出的时间是1970-01-01T00:00:00Z与我想要的时间,差距过大。
这是我的代码

        Long timestamp = jsonParser.getLongValue();System.out.println("时间戳:" + timestamp);LocalDate localDate = Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.ofHours(8)).toLocalDate();LocalDateTime localDateTime = Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.ofHours(8)).toLocalDateTime();System.out.println("LocalDate:" + localDate);System.out.println("LocalDateTime:" + localDateTime);

控制台输出

特意去百度了一下,发现是时间单位问题,我也不太清楚,我是菜鸡。
特地去阿里云的时间戳转换根据测试了一下。

时间戳转换为当前时间,当是秒的时候。

这是毫秒的时间戳转换

可以发现当我们单位是毫秒的时候都输出LocalDateTime的纪元参考点是UTC的1970-01-01T00:00:00Z

解决办法
时间戳这里乘以1000就可以了

   Long timestamp = jsonParser.getLongValue()*1000;System.out.println("时间戳:" + timestamp);LocalDate localDate = Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.ofHours(8)).toLocalDate();LocalDateTime localDateTime = Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.ofHours(8)).toLocalDateTime();System.out.println("LocalDate:" + localDate);System.out.println("LocalDateTime:" + localDateTime);

时间戳转换LocalDateTime输出为1970-01-01T00:00:00Z相关推荐

  1. Long型 时间戳转换 得到格林时间 格式:2020-02-25T16:00:00.00Z

    public static final SimpleDateFormat DATE_TIME_ZONE = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm: ...

  2. python 时间戳转换_python 时间戳

    python时间戳和日期转换 做项目的时候会经常涉及到时间和日期之间的转换,在此记录下来,其实就是几个函数的调用: 时间戳转日期 显示系统当前时间戳:time.time(),返回float型 time ...

  3. java时间戳与LocalDateTime常用转换方式

    1 Date.LocalDate.LocalTime.LocalDateTime与时间戳的转换 在时间转换中,ZoneOffset表示偏移量,北京时间是+8,一般写为:ZoneOffset.of(&q ...

  4. LocalDateTime时间戳转换

    1.LocalDate转DateLocalDate nowLocalDate = LocalDate.now(); Date date = Date.from(localDate.atStartOfD ...

  5. 数据挖掘 (一)——ASC文件读写、时间戳转换、可执行文件打包

    一.时间戳介绍 云平台上的数据通常以timestamp为时间戳,现在有个需求,需要将timestamp时间转换成datetime时间 TimesTamp,一个能表示一份数据在某个特定时间之前已经存在的 ...

  6. mysql 13位时间戳转时间戳_时间戳换算(13位时间戳转换工具 在线)

    以前遇到过一个关于时间戳的问题,为了不被大家鄙视,先说一下概念. 具体时间戳怎么定义的我也不清楚,但百度百科中有这么一句:"时间戳是自 1970 年 1 月 1 日(. 本来下午能解答的.. ...

  7. linux 时间戳13,13/11位unix时间戳转换成标准时间

    使用范例 char *str="1320718222932"; long long time1; sscanf(str,"%I64d",&time); ...

  8. java-学习笔记-java时间戳转换日期格式

    import java.text.SimpleDateFormat; import java.util.Date;public class DateUtil {/** * 时间戳转换成日期格式字符串 ...

  9. python unix时间戳转换成时间_关于python:将unix时间戳字符串转换为可读日期

    我有一个用python表示unix时间戳(即"1284101485")的字符串,我想把它转换成一个可读的日期.当我使用time.strftime时,我得到一个TypeError: ...

最新文章

  1. 浅谈CSS重构样式表性能
  2. ThinkPHP5验证码不显示的原因及解决方法
  3. 七十七、SpringBoot整合Rabbitmq
  4. python实现计算字符串或列表中每个字符出现的次数,并打印出现次数最多的字符
  5. 工业交换机的单模和多模能否互相替代?
  6. vs entityframwork Validation failed for one or more entities
  7. Github入门详情教程
  8. oracle 列 连续,sql 查寻某列连续的几个值是否相同
  9. Shell脚本之awk详解
  10. 数据集:各地区化妆品销量、人口数量和人均收入
  11. 史上最全的芯片封装介绍
  12. 计算机财务管理中表格的应用,excel在财务管理中的应用学习心得
  13. Uniformly Distributed
  14. TypeScript 学习笔记(十万字超详细知识点总结)
  15. 为何日本手机走不出国门?
  16. 前端React教程第六课 认识栈调和、setState和Fiber架构
  17. 博客园背景滴墨水特效
  18. 质量统计分析人工智能应用APP
  19. Already included file name #2372
  20. 液位控制系统c语言程序,水槽液位控制系统课程设计报告.doc

热门文章

  1. 智慧养老解决方案是未来带领老人走向健康的黑科技
  2. Fastdata极数:2020中国K12在线教育行业报告
  3. 稠密点云重建MVS——基于多视角深度图像
  4. 焦虑的注意偏向研究有哪些方法?
  5. u盘部分文件无故消失,要怎么找回?
  6. 【TortoiseGit】本地仓库文件夹无故出红色叹号
  7. 社工计算机操作考试时间,社工证每年什么时间考试
  8. wls matlab code,【 MATLAB】 Two-step WLS algorithm Simulation of TOA - Based Positioning
  9. php 长链接变为短链接,长链接转短链接原理
  10. linux 查看硬盘的uuid_linux blkid命令显示块设备属性查看硬盘UUID号