com.github.sourcegroove.jackson.module.serialization.OffsetDateTimeSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-simple-date-module Show documentation
Show all versions of jackson-simple-date-module Show documentation
Layout driven spring batch item readers and writers
package com.github.sourcegroove.jackson.module.serialization;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.github.sourcegroove.jackson.module.DateRepresentation;
import com.github.sourcegroove.jackson.module.DateRepresentationType;
import java.io.IOException;
import java.time.OffsetDateTime;
public class OffsetDateTimeSerializer extends JsonSerializer {
private DateRepresentationType type;
public OffsetDateTimeSerializer(DateRepresentationType type){
this.type = type;
}
@Override
public void serialize(OffsetDateTime value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
if(value != null) {
jsonGenerator.writeObject(new DateRepresentation(this.type).of(value).serialize());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy