Skip to content

Commit

Permalink
add testcase for issue #1325
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 7, 2023
1 parent c7f30c5 commit 1e5d67f
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.alibaba.fastjson2.issues_1000;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.util.DateUtils;
import org.junit.jupiter.api.Test;

import java.util.Date;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue1325 {
@Test
public void test() {
Date date = DateUtils.parseDate( "2022-02-16T16:00:00.000Z");
String str = " {\"activeDate\": \"2022-02-16T16:00:00.000Z\"}";
assertEquals(
date.getTime(),
JSON.parseObject(str, Bean.class)
.activeDate
.getTime()
);
assertEquals(
date.getTime(),
JSON.parseObject(str.toCharArray(), Bean.class)
.activeDate
.getTime()
);
assertEquals(
date.getTime(),
JSON.parseObject(str.getBytes(), Bean.class)
.activeDate
.getTime()
);
}

public static class Bean {
public Date activeDate;
}
}

0 comments on commit 1e5d67f

Please sign in to comment.