add TemporalAccessorSerializer

This commit is contained in:
Looly
2022-02-17 11:53:57 +08:00
parent 10f65045e3
commit 4b56b545e7
7 changed files with 162 additions and 39 deletions

View File

@@ -5,6 +5,8 @@ import org.junit.Assert;
import org.junit.Test;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
/**
@@ -29,6 +31,30 @@ public class Issue2090Test {
Assert.assertNotNull(jsonObject.toString());
}
@Test
public void toBeanLocalDateTest(){
LocalDate d = LocalDate.now();
final JSONObject obj = JSONUtil.parseObj(d);
LocalDate d2 = obj.toBean(LocalDate.class);
Assert.assertEquals(d, d2);
}
@Test
public void toBeanLocalDateTimeTest(){
LocalDateTime d = LocalDateTime.now();
final JSONObject obj = JSONUtil.parseObj(d);
LocalDateTime d2 = obj.toBean(LocalDateTime.class);
Assert.assertEquals(d, d2);
}
@Test
public void toBeanLocalTimeTest(){
LocalTime d = LocalTime.now();
final JSONObject obj = JSONUtil.parseObj(d);
LocalTime d2 = obj.toBean(LocalTime.class);
Assert.assertEquals(d, d2);
}
@Test
public void monthTest(){
final JSONObject jsonObject = new JSONObject();