diff --git a/pom.xml b/pom.xml index b75ae7fb86..156faf0664 100644 --- a/pom.xml +++ b/pom.xml @@ -96,8 +96,8 @@ 3.8.0 UTF-8 - 1.8 - 1.8 + ${jdk.version} + ${jdk.version} @@ -154,7 +154,7 @@ 3.0.0-M5 - **/CustomSuiteTest.java + **/bvt/**/*.java diff --git a/src/test/java/com/alibaba/json/bvt/issue_2700/Issue2784.java b/src/test/java/com/alibaba/json/bvt/issue_2700/Issue2784.java index caa4db40c5..09f848c2a0 100644 --- a/src/test/java/com/alibaba/json/bvt/issue_2700/Issue2784.java +++ b/src/test/java/com/alibaba/json/bvt/issue_2700/Issue2784.java @@ -11,16 +11,31 @@ public class Issue2784 extends TestCase { public void test_for_issue() throws Exception { Model m = new Model(); - m.time = java.time.LocalDateTime.now(); + m.time = waitUntilZeroBeyondMillis(); + String str = JSON.toJSONString(m); assertEquals("{\"time\":" + m.time.atZone(JSON.defaultTimeZone.toZoneId()).toInstant().toEpochMilli() + "}", str); - Model m1 = JSON.parseObject(str, Model.class); assertEquals(m.time, m1.time); } + private static LocalDateTime waitUntilZeroBeyondMillis() throws InterruptedException { + while (true) { + LocalDateTime currentTime = LocalDateTime.now(); + ZonedDateTime zoned = currentTime.atZone(JSON.defaultTimeZone.toZoneId()); + + System.out.println("SEC:"+zoned.toInstant().getNano() % 1000000); + if (zoned.toInstant().getNano() % 1000000 == 0 ) { + return currentTime; + } + + // Wait for a short interval before checking again + Thread.sleep(10); + } + } + public void test_for_issue_1() throws Exception { Model m = new Model(); m.ztime = ZonedDateTime.now();