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

ec.gob.senescyt.sniese.commons.serializers.JSONFechaSerializer Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
package ec.gob.senescyt.sniese.commons.serializers;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import ec.gob.senescyt.sniese.commons.Constantes;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.io.IOException;

public class JSONFechaSerializer extends JsonSerializer {

    DateTimeFormatter fmt = DateTimeFormat.forPattern(Constantes.DATE_FORMAT).withZone(DateTimeZone.UTC);

    @Override
    public void serialize(DateTime date, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeString(date.toString(fmt));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy