首页 > 其他分享 >fastjson将date转换成了long

fastjson将date转换成了long

时间:2023-06-28 17:44:34浏览次数:42  
标签:fastjson 转换成 long 版本 date 2.0

 

记录一个bug,这个问题是使用fastjson的时候遇到了将date的数据转换成long类型而不是转换成string

环境

  fastjson使用的是1.2.76

造成的原因

  更具环境大家可能已经猜测到了真实的原因-版本太低造成的。这个项目的存在时间比较久所以在使用的依赖上版本比较低,除了源码之外在后续的校验中采用了2.0.0版本进行测试时没有问题的,所以看来在fastjson在高版本的验证验证上已经修复了这个问题,当然这个可能并不是bug可能是当时开发的设想是有什么考量,所以在不升级版本的时候是存在解决方案的

解决方案

1.升级fastjson的版本

  在后续的验证中采用了2.0.0的版本,可以正常转换。

2.不升级版本

  2.1使用fastjson的api

JSON.toJSONStringWithDateFormat("参数","yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat);

  2.2sql函数控制

 

标签:fastjson,转换成,long,版本,date,2.0
From: https://www.cnblogs.com/zsrecord/p/17512081.html

相关文章

  • ionic3安卓触发返回键ion-datetime不自动关闭
    框架:ionic3+angular机型:安卓问题:点击打开ion-datetime选择框,直接使用物理返回键(或自带的滑动返回)时,页面返回上一页但ion-datetime弹窗仍未关闭。理想情况:返回时会自动关闭ion-datetime弹窗再返回上一页解决方法://page.tsimport{Platform}from'ionic-angular';.........
  • Python time和datetime模块
    Pythontime和datetime模块标准库time与datetime时间的3中格式:时间戳时间戳-->struct_timetime.gmtime(UTC时间)time.localtime(本地时区时间)struct_time()struct_time-->时间戳time.mktimestruct_time-->格式化的字......
  • java8 LocalDateTime/LocalDate/LocalTime、java.util.Date/java.sql.Date区别及日期
    先介绍一下,LocalDateTime/LocalDate/LocalTime、java.util.Date/java.sql.Date区别LocalDateTime/LocalDate/LocalTimejava.time.LocalDateTime,是一个日期+时间,不带时区,它是个不可更改对象,精确到纳秒。它的日期可以认为是生日,它的时间可以认为是挂钟的时间,比较LocalDateTime时用eq......
  • 限制Element ui日期选择器el-date-picker时间跨度为3个月
    处理Element日期选择器el-date-picker限制时间跨度3个月。主要通过pickerOptions里的disabledDate来控制禁止选中的日期。实现思想就是,当选中第一个开始日期时,拿到该时间戳计算时间范围,然后控制接下来选中时间在3个月以内,超过范围禁用掉。1、在template中使用el-date-pic......
  • Windows Server 2022 中文版、英文版下载 (updated Jun 2023)
    WindowsServer2022中文版、英文版下载(updatedJun2023)WindowsServer2022正式版,2023年6月更新请访问原文链接:https://sysin.org/blog/windows-server-2022/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org早期直观体验版本21H2,根据名称预计今年秋季......
  • Windows 10, version 22H2 (updated Jun 2023) 中文版、英文版下载
    Windows10,version22H2(updatedJun2023)中文版、英文版下载Windows1022H2企业版arm64x64请访问原文链接:https://sysin.org/blog/windows-10/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgWindows10更新历史记录Windows10,version22H2,alledit......
  • Windows 11 22H2 中文版、英文版 (x64、ARM64) 下载 (updated Jun 2023)
    Windows1122H2中文版、英文版(x64、ARM64)下载(updatedJun2023)Windows11,version22H2,2023年6月更新请访问原文链接:https://sysin.org/blog/windows-11/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org全新推出Windows11全新Windows体验,让您与热......
  • clickhouse数据库里面,类型 datetime, datetime64, datetime(3), datetime64(3)
     问:clickhouse数据库里面,类型datetime,datetime64,datetime(3),datetime64(3)分别是什么意思,举例详细说明 答:在ClickHouse数据库中,有以下几种日期时间类型:DateTime:这是一个8字节的整数类型,表示从公元1年1月1日开始的秒数。它只能存储到秒级别的精度。Dat......
  • C# DateTime去掉时分秒几种方法
    https://blog.csdn.net/qq_38730092/article/details/105784412DateTime now=DateTime.Parse(“2015/01/2313:50:00”);Console.WriteLine(now.Date);//去掉时分秒,返回DateTimeConsole.WriteLine(now.ToShortDateString());//去掉时分秒,返回stringConsole.WriteLine(now.To......
  • SimpleDateFormat 线程不安全!使用DateTimeFormatter
    1、报错原因:(1)、SimpleDateFormat是线程不安全的(2)、代码想把格林威治时间转换成yyyy-MM-ddHH:mm:ss报错Exceptioninthread:java.lang.NumberFormatException:Forinputstring:""类似下图的错误: 2、解决方案:使用DateTimeFormatter//时间转换DateTimeFor......