io.github.dft.cario.model.common.LocalDateSerializer Maven / Gradle / Ivy
The newest version!
package io.github.dft.cario.model.common;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import lombok.SneakyThrows;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class LocalDateSerializer extends JsonSerializer {
private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
@Override
@SneakyThrows
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializers) {
gen.writeString(formatter.format(value));
}
}