com.bitpay.sdk.util.serializer.Iso8601ToZonedDateTimeDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bitpay_sdk Show documentation
Show all versions of bitpay_sdk Show documentation
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);
}
}