From eb9fb655447b19f0ede50d6b795afb03a74bc151 Mon Sep 17 00:00:00 2001 From: "rui.zhang" Date: Thu, 5 Mar 2020 08:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If1c03b641341f9287061c2c58c64ff389056189b --- src/main/java/org/chobit/wp/tools/JsonKit.java | 5 +++++ src/test/java/org/chobit/wp/WordPressTest.java | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/org/chobit/wp/tools/JsonKit.java b/src/main/java/org/chobit/wp/tools/JsonKit.java index 6b14569..154517b 100644 --- a/src/main/java/org/chobit/wp/tools/JsonKit.java +++ b/src/main/java/org/chobit/wp/tools/JsonKit.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; +import java.text.SimpleDateFormat; /** * @author robin @@ -24,6 +25,10 @@ public abstract class JsonKit { MAPPER.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); MAPPER.setSerializationInclusion(JsonInclude.Include.NON_ABSENT); MAPPER.setDefaultPropertyInclusion(JsonInclude.Include.NON_DEFAULT); + + SimpleDateFormat defaultDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + MAPPER.setDateFormat(defaultDateFormat); } diff --git a/src/test/java/org/chobit/wp/WordPressTest.java b/src/test/java/org/chobit/wp/WordPressTest.java index 6aa7b0d..5ad7e83 100644 --- a/src/test/java/org/chobit/wp/WordPressTest.java +++ b/src/test/java/org/chobit/wp/WordPressTest.java @@ -76,6 +76,7 @@ public class WordPressTest { post.setCategories("分类"); post.setTags("a", "b", "c"); post.setPostName("test-post-name"); + post.setPostDateGmt(System.currentTimeMillis()); int postId = wp.newPost(post); System.out.println(postId); Assert.assertNotNull(postId);