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

com.gooddata.sdk.common.util.GDDateSerializer Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
/*
 * 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.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.joda.time.LocalDate;

import java.io.IOException;

import static com.gooddata.sdk.common.util.GDDateDeserializer.FORMATTER;

/**
 * Serializes from Joda's {@link LocalDate} fields to the GoodData date time format (yyyy-MM-dd).
 */
public class GDDateSerializer extends JsonSerializer {

    @Override
    public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider arg2) throws IOException {
        gen.writeString(FORMATTER.print(value));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy