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

com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer Maven / Gradle / Ivy

Go to download

Full implementation of the BitPay Payment Gateway. This library implements BitPay's Cryptographically Secure RESTful API.

The newest version!
/*
 * Copyright (c) 2019 BitPay.
 * All rights reserved.
 */

package com.bitpay.sdk.util.serializer;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.node.TextNode;
import java.io.IOException;
import java.time.ZonedDateTime;

public class Iso8601ToZonedDateTimeDeserializer extends JsonDeserializer {
    @Override
    public ZonedDateTime deserialize(
        JsonParser jsonParser,
        DeserializationContext deserializationContext
    ) throws IOException {
        TextNode node = jsonParser.getCodec().readTree(jsonParser);
        String dateAsString = node.asText();

        return ZonedDateTime.parse(dateAsString);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy