io.github.dft.mayers.common.LocalDateTimeSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mayers-sdk Show documentation
Show all versions of mayers-sdk Show documentation
mayers-sdk API using JDK 11
The newest version!
package io.github.dft.mayers.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.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeSerializer extends JsonSerializer {
private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
@Override
@SneakyThrows
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) {
gen.writeString(formatter.format(value));
}
}