-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
toJavaObject support LocalDateTime, for issue #3091
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
core/src/test/java/com/alibaba/fastjson2/issues_3000/Issue3091.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.alibaba.fastjson2.issues_3000; | ||
|
||
import com.alibaba.fastjson2.JSONObject; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class Issue3091 { | ||
@Test | ||
public void test() { | ||
String json = "{\"time\":0}"; | ||
JSONObject jsonObject = JSONObject.parseObject(json); | ||
Time2 bean = jsonObject.toJavaObject(Time2.class); | ||
assertNotNull(bean.time); | ||
assertEquals(1970, bean.time.getYear()); | ||
} | ||
|
||
@Data | ||
public static class Time2 { | ||
private LocalDateTime time; | ||
} | ||
} |