![JAR search and dependency download from the Maven repository](/logo.png)
com.despegar.integration.mongo.support.DateJsonDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongo-connector Show documentation
Show all versions of mongo-connector Show documentation
Helper component to connect to mongo fast and easy
package com.despegar.integration.mongo.support;
import java.io.IOException;
import java.util.Date;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
public class DateJsonDeserializer
extends JsonDeserializer {
@Override
public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonToken t = jp.getCurrentToken();
if (t == JsonToken.VALUE_EMBEDDED_OBJECT) {
Date date = (Date) jp.getEmbeddedObject();
return date;
} else {
throw new RuntimeException("Invalid date format. ISODate was expected.");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy