package cn.quantgroup.xyqb.config.http;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;

import java.lang.reflect.Type;
import java.sql.Timestamp;

/**
 * Created by Miraculous on 2016/12/29.
 */
public class Timestamp2LongConverter implements ObjectSerializer {
    ;

    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) {
        Timestamp time = (Timestamp) object;
        if (time == null) {
            serializer.write(String.valueOf(0L));
        } else {
            serializer.write(String.valueOf(time.getTime()));
        }
    }
}
