[BUG]对象转JsonString后,时间发生变化
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
fastjson版本从1.2.83升级到2.0.49之后,日期转为jsonString时,日期发生改变
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:Windows 11]
- JDK信息: [e.g.:Openjdk 1.8.0_312]
- 版本信息:[e.g.:Fastjson 2.0.49]
### 重现步骤
*如何操作可以重现该问题:*
String dateStr = "1900-01-01 00:06:43.0";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
Date date = simpleDateFormat.parse(dateStr);
System.out.println(date);
System.out.println(JSON.toJSONString(date, SerializerFeature.WriteDateUseDateFormat));

### 相关日志输出
*请复制并粘贴任何相关的日志输出。*
打印结果如下:

Contributor guide
Research direction
Start by running the supplied SimpleDateFormat and JSON.toJSONString example with Fastjson 1.2.83 and 2.0.49, comparing the serialized value for the 1900-01-01 date. Trace the date serialization path reached by JSON.toJSONString with SerializerFeature.WriteDateUseDateFormat. Done means the date is serialized without the reported change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100