Skip to content

Commit

Permalink
add testcase for issue #2124
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 6, 2024
1 parent 3e019b6 commit d3eec0b
Showing 1 changed file with 28 additions and 0 deletions.
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);
}
}

0 comments on commit d3eec0b

Please sign in to comment.