package fastweb.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.joda.time.DateTime;

import java.io.IOException;
import java.util.Date;

/**
 * @author: hengrui.liu
 * @createTime 2023年 03月30日 13:34
 **/
public class Date2StringShortSerializer  extends JsonSerializer<Date> {
    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {//把Date转成Lon

        DateTime dateTime = new DateTime(date);
        jsonGenerator.writeString(dateTime.toString("yyyy-MM-dd"));
    }
}