com.github.sourcegroove.jackson.module.serialization.ZonedDateTimeSerializer 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.ZonedDateTime;
public class ZonedDateTimeSerializer extends JsonSerializer {
private DateRepresentationType type;
public ZonedDateTimeSerializer(DateRepresentationType type){
this.type = type;
}
@Override
public void serialize(ZonedDateTime 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