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

io.github.dft.amazon.common.DateDeserializer Maven / Gradle / Ivy

There is a newer version: 2.1.9
Show newest version
package io.github.dft.amazon.common;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateDeserializer extends JsonDeserializer {

    @Override
    public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
        String timestamp = jsonParser.getText()
                                     .trim();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss[.XXX]");
        return LocalDateTime.parse(timestamp, dateTimeFormatter);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy