com.gooddata.sdk.common.util.GDDateTimeDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gooddata-rest-common Show documentation
Show all versions of gooddata-rest-common Show documentation
GoodData REST Common Library
/*
* Copyright (C) 2004-2017, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.sdk.common.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.joda.time.DateTime;
import java.io.IOException;
import static com.gooddata.sdk.common.util.GDDateTimeSerializer.FORMATTER;
/**
* Deserialize Joda's {@link DateTime} fields from the GoodData date time format in the UTC timezone (yyyy-MM-dd HH:mm:ss.SSSZ).
*/
public class GDDateTimeDeserializer extends JsonDeserializer {
@Override
public DateTime deserialize(JsonParser jp, DeserializationContext ctx) throws IOException {
final JsonNode root = jp.readValueAsTree();
if (root == null || root.isNull()) {
return null;
}
return FORMATTER.parseDateTime(root.textValue());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy