ph.com.nightowlstudios.entity.serializer.LocalDateDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edge Show documentation
Show all versions of edge Show documentation
A simple library for building REST API using Vertx.
package ph.com.nightowlstudios.entity.serializer;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import java.io.IOException;
import java.time.LocalDate;
/**
* @author Joseph Harvey Angeles - yev
* @since 8/11/21
**/
public class LocalDateDeserializer extends StdDeserializer {
protected LocalDateDeserializer() {
this(LocalDate.class);
}
protected LocalDateDeserializer(Class> vc) {
super(vc);
}
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
try {
return LocalDate.parse(p.getText());
} catch (NumberFormatException e) {
return LocalDate.parse(LocalDate.now().toString());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy