-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
core/src/test/java/com/alibaba/fastjson2/issues_2100/Issue2124.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.*; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.ZoneId; | ||
import java.util.Date; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class Issue2124 { | ||
@Test | ||
public void test() { | ||
ZoneId zoneId = ZoneId.of("Asia/Karachi"); | ||
|
||
JSONWriter.Context writeContext = JSONFactory.createWriteContext(); | ||
writeContext.setZoneId(zoneId); | ||
|
||
Date date = new Date(); | ||
String str = JSON.toJSONString(date, writeContext); | ||
|
||
JSONReader.Context readContext = JSONFactory.createReadContext(); | ||
readContext.setZoneId(zoneId); | ||
|
||
Date date1 = JSON.parseObject(str, Date.class, readContext); | ||
assertEquals(date, date1); | ||
} | ||
} |