-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse date support more format, for issue #2199
- Loading branch information
Showing
2 changed files
with
32 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
core/src/test/java/com/alibaba/fastjson2/issues_2100/Issue2199.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,28 @@ | ||
package com.alibaba.fastjson2.issues_2100; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONObject; | ||
import com.alibaba.fastjson2.annotation.JSONField; | ||
import lombok.Data; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Date; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2199 { | ||
@Data | ||
public static class Obj1 { | ||
@JSONField(format = "yyyy-MM-dd hh:mm:ss") | ||
private Date startTime; | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
Obj1 orderBO = new Obj1(); | ||
orderBO.setStartTime(new Date()); | ||
String s = JSONObject.toJSONString(orderBO); | ||
Obj1 obj1 = JSONObject.parseObject(s, Obj1.class); | ||
assertEquals(s, JSON.toJSONString(obj1)); | ||
} | ||
} |