All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dft.mayers.common.LocalDateTimeSerializer Maven / Gradle / Ivy

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));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy