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

io.github.lc.oss.commons.serialization.InstantSerializer Maven / Gradle / Ivy

Go to download

A common serializtion framework to help avoid accidental de/serializtion of object instances

The newest version!
package io.github.lc.oss.commons.serialization;

import java.io.IOException;
import java.time.Instant;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

public class InstantSerializer extends JsonSerializer {
    @Override
    public void serialize(Instant value, JsonGenerator gen, SerializerProvider serializer) throws IOException {
        if (value == null) {
            gen.writeNull();
        } else {
            gen.writeNumber(value.toEpochMilli());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy