All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.sstoehr.harreader.jackson.ExceptionIgnoringZonedDateTimeDeserializer Maven / Gradle / Ivy

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