net.nemerosa.ontrack.json.JDKLocalDateTimeSerializer Maven / Gradle / Ivy
package net.nemerosa.ontrack.json;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
public class JDKLocalDateTimeSerializer extends JsonSerializer {
@Override
public void serialize(LocalDateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value != null) {
jgen.writeString(value.toInstant(ZoneOffset.UTC).toString());
} else {
jgen.writeNull();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy