Skip to content

Commit

Permalink
add testcase for issue #2435
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 13, 2024
1 parent a77bb6c commit 686fe3e
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.alibaba.fastjson2.issues_2400;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.annotation.JSONField;
import org.junit.jupiter.api.Test;

import java.util.Date;

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

public class Issue2435 {
@Test
public void test() {
Bean bean = JSON.parseObject("{\"date\":\"2014-07-14 12:13\"}", Bean.class);
assertNotNull(bean.date);
assertEquals("{\"date\":\"2014-07-14 12:13:00\"}", JSON.toJSONString(bean));
}

public static class Bean {
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
public Date date;
}
}

0 comments on commit 686fe3e

Please sign in to comment.