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

org.vfdtech.entitity_related.JacksonLocalDateTimeSerializer Maven / Gradle / Ivy

Go to download

A utilities service with generic tools implementation. Can be plugged into your java project. This is designed for Java 1.8

There is a newer version: 1.0.0
Show newest version
package org.vfdtech.entitity_related;

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.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class JacksonLocalDateTimeSerializer extends StdSerializer {
    private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;

    protected JacksonLocalDateTimeSerializer() {
        super(LocalDateTime.class);
    }

    @Override
    public void serialize(LocalDateTime localDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(formatter.format(localDateTime));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy