io.github.eduardromanyuk.turbosms.json.LocalDateTimeDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of turbosms-spring-boot-starter Show documentation
Show all versions of turbosms-spring-boot-starter Show documentation
This starter provides infrastructure for using TurboSMS sms/viber provider.
HTTP API was used for communication.
The newest version!
package io.github.eduardromanyuk.turbosms.json;
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.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeDeserializer extends StdDeserializer {
protected LocalDateTimeDeserializer() {
super(LocalDateTime.class);
}
@Override
public LocalDateTime deserialize(JsonParser jp, DeserializationContext deserializationContext) throws IOException {
return LocalDateTime.parse(
jp.getCodec().readValue(jp, String.class),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
);
}
}