ec.gob.senescyt.sniese.commons.deserializers.JSONFechaDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sniese-commons Show documentation
Show all versions of sniese-commons Show documentation
Librería que contiene clases de uso comun para sniese hechos en dropwizard
package ec.gob.senescyt.sniese.commons.deserializers;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
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 JSONFechaDeserializer extends JsonDeserializer {
DateTimeFormatter fmt = DateTimeFormat.forPattern(Constantes.DATE_FORMAT);
@Override
public DateTime deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
String fechaSerializada = jsonParser.getText();
if (fechaSerializada.isEmpty()) {
return null;
}
return fmt.parseDateTime(fechaSerializada).withZone(DateTimeZone.UTC).withTimeAtStartOfDay();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy