io.github.dft.mayers.common.LocalDateTimeDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mayers-sdk Show documentation
Show all versions of mayers-sdk Show documentation
mayers-sdk API using JDK 11
The newest version!
package io.github.dft.mayers.common;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import lombok.SneakyThrows;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class LocalDateTimeDeserializer extends JsonDeserializer {
@Override
@SneakyThrows
public LocalDateTime deserialize(JsonParser parser, DeserializationContext context) {
String dateStr = parser.getText();
return LocalDateTime.parse(dateStr, DateTimeFormatter.ISO_DATE_TIME);
}
}