de.sstoehr.harreader.jackson.ExceptionIgnoringZonedDateTimeDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of har-reader Show documentation
Show all versions of har-reader Show documentation
A library to access HTTP archive format with Java
The newest version!
package de.sstoehr.harreader.jackson;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
import java.io.IOException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class ExceptionIgnoringZonedDateTimeDeserializer extends JsonDeserializer {
@Override
public ZonedDateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
try {
return InstantDeserializer.ZONED_DATE_TIME.deserialize(jp, ctxt);
} catch (IOException e) {
//ignore
}
return ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), ZoneId.of("UTC"));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy