mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
fix time
This commit is contained in:
parent
04e115ce03
commit
d7b32d24f9
@ -13,6 +13,7 @@ import me.chanjar.weixin.common.util.json.GsonHelper;
|
||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class WxMpMaterialNewsGsonAdapter implements JsonSerializer<WxMpMaterialNews>, JsonDeserializer<WxMpMaterialNews> {
|
||||
@ -28,6 +29,16 @@ public class WxMpMaterialNewsGsonAdapter implements JsonSerializer<WxMpMaterialN
|
||||
}
|
||||
newsJson.add("articles", articleJsonArray);
|
||||
|
||||
if (wxMpMaterialNews.getCreatedTime() != null) {
|
||||
newsJson.addProperty("create_time",
|
||||
SimpleDateFormat.getDateTimeInstance().format(wxMpMaterialNews.getCreatedTime()));
|
||||
}
|
||||
|
||||
if (wxMpMaterialNews.getUpdatedTime() != null) {
|
||||
newsJson.addProperty("update_time",
|
||||
SimpleDateFormat.getDateTimeInstance().format(wxMpMaterialNews.getUpdatedTime()));
|
||||
}
|
||||
|
||||
return newsJson;
|
||||
}
|
||||
|
||||
@ -45,12 +56,12 @@ public class WxMpMaterialNewsGsonAdapter implements JsonSerializer<WxMpMaterialN
|
||||
}
|
||||
|
||||
if (json.get("create_time") != null && !json.get("create_time").isJsonNull()) {
|
||||
Date createTime = new Date(GsonHelper.getAsLong(json.get("create_time")));
|
||||
Date createTime = new Date(GsonHelper.getAsLong(json.get("create_time"))* 1000);
|
||||
wxMpMaterialNews.setCreatedTime(createTime);
|
||||
}
|
||||
|
||||
if (json.get("update_time") != null && !json.get("update_time").isJsonNull()) {
|
||||
Date updateTime = new Date(GsonHelper.getAsLong(json.get("update_time")));
|
||||
Date updateTime = new Date(GsonHelper.getAsLong(json.get("update_time"))* 1000);
|
||||
wxMpMaterialNews.setUpdatedTime(updateTime);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user