ph.com.nightowlstudios.entity.serializer.LocalDateTimeSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edge Show documentation
Show all versions of edge Show documentation
A simple library for building REST API using Vertx.
package ph.com.nightowlstudios.entity.serializer;
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.ZoneId;
/**
* @author Joseph Harvey Angeles - yev
* @since 4/10/21
**/
public class LocalDateTimeSerializer extends StdSerializer {
protected LocalDateTimeSerializer() {
this(LocalDateTime.class);
}
protected LocalDateTimeSerializer(Class t) {
super(t);
}
@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider provider) throws IOException {
Long epoch = value.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
gen.writeString(epoch.toString());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy