alibaba / alibaba/fastjson2

[BUG]com.alibaba.fastjson2.JSONObject#getDate无法解析2023-12-01 00:00:00及之后的数据

Open
#2,064 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 问题描述
*简要描述您碰到的问题。*
com.alibaba.fastjson2.JSONObject#getDate无法解析2023-12-01 00:00:00及之后的数据,报java.time.format.DateTimeParseException: illegal input

### 环境信息
*请填写以下信息:*

- OS信息: [e.g.:Ubuntu 22.04]
- JDK信息: [e.g.:OracleJDK 17.0.5]
- 版本信息:[e.g.:Fastjson2 2.0.19]

### 重现步骤
*如何操作可以重现该问题:*

1. 使用 `com.alibaba.fastjson2.JSONObject#getDate` 方法
2. 输入 `2023-12-01 00:00:00` 数据
3. 出现 `java.time.format.DateTimeParseException: illegal input` 错误
```java
//可在此输入示例代码
import com.alibaba.fastjson2.JSONObject;

public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("time", "2023-12-01 00:00:00");
System.out.println(jsonObject.getDate("time"));
}
```

### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
getDate方法获取到正确的数据

### 相关日志输出
*请复制并粘贴任何相关的日志输出。*

#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*
![微信截图_20231201112915](https://github.com/alibaba/fastjson2/assets/41881921/5cefc3e8-0f9c-46b1-86be-13faa820d18a)
![微信截图_20231201112950](https://github.com/alibaba/fastjson2/assets/41881921/68911f6e-498c-474a-8a18-824ace19bdc6)

Contributor guide

Open the contributing guide

Research direction

Start with the provided JSONObject#getDate reproduction using the input "2023-12-01 00:00:00" and inspect the date parsing path that raises DateTimeParseException. Done means getDate returns the corresponding date successfully for this input and for dates on or after 2023-12-01.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.