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

io.prestosql.jdbc.$internal.jackson.datatype.jsr310.deser.key.InstantKeyDeserializer Maven / Gradle / Ivy

The newest version!
package io.prestosql.jdbc.$internal.jackson.datatype.jsr310.deser.key;

import java.io.IOException;
import java.time.DateTimeException;
import java.time.Instant;
import java.time.format.DateTimeFormatter;

import io.prestosql.jdbc.$internal.jackson.databind.DeserializationContext;

public class InstantKeyDeserializer extends Jsr310KeyDeserializer {

    public static final InstantKeyDeserializer INSTANCE = new InstantKeyDeserializer();

    private InstantKeyDeserializer() {
        // singleton
    }

    @Override
    protected Instant deserialize(String key, DeserializationContext ctxt) throws IOException {
        try {
            return DateTimeFormatter.ISO_INSTANT.parse(key, Instant::from);
        } catch (DateTimeException e) {
            return _handleDateTimeException(ctxt, Instant.class, e, key);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy