This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fixed for support < 1970 date deserialize, for issue #1772
- Loading branch information
Showing
2 changed files
with
35 additions
and
3 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
27 changes: 27 additions & 0 deletions
27
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1772.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,27 @@ | ||
package com.alibaba.json.bvt.issue_1700; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONObject; | ||
import junit.framework.TestCase; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class Issue1772 extends TestCase { | ||
public void test_0() throws Exception { | ||
Date date = JSON.parseObject("\"-14189155200000\"", Date.class); | ||
assertEquals(-14189155200000L, date.getTime()); | ||
} | ||
|
||
public void test_1() throws Exception { | ||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("time", "-14189155200000"); | ||
|
||
Model m = jsonObject.toJavaObject(Model.class); | ||
assertEquals(-14189155200000L, m.time.getTime()); | ||
} | ||
|
||
public static class Model { | ||
public Date time; | ||
} | ||
} |