ai.databand.schema.jackson.ZonedDateTimeSerializer Maven / Gradle / Ivy
package ai.databand.schema.jackson;
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.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class ZonedDateTimeSerializer extends StdSerializer {
private static final String PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX";
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern(PATTERN);
public ZonedDateTimeSerializer() {
this(null);
}
public ZonedDateTimeSerializer(Class t) {
super(t);
}
@Override
public void serialize(ZonedDateTime value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeString(value.format(FORMATTER));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy