ai.databand.schema.jackson.LocalDateSerializer Maven / Gradle / Ivy
package ai.databand.schema.jackson;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class LocalDateSerializer extends StdSerializer {
private final String PATTERN = "yyyy-MM-dd";
private final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(PATTERN);
public LocalDateSerializer() {
this(null);
}
public LocalDateSerializer(Class t) {
super(t);
}
@Override
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeString(value.format(FORMATTER));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy