mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
加入微信接口中时间类型的序列化转换类,供转换json使用
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package me.chanjar.weixin.mp.util.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
/**
|
||||
* Created by Binary Wang on 2016/7/13.
|
||||
*/
|
||||
public class WxLongTimeJsonSerializer extends JsonSerializer<Long> {
|
||||
private static SimpleDateFormat DF = new SimpleDateFormat(
|
||||
"yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
@Override
|
||||
public void serialize(Long value, JsonGenerator gen,
|
||||
SerializerProvider serializers)
|
||||
throws IOException, JsonProcessingException {
|
||||
gen.writeString(DF.format(value * 1000));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user