
org.dspace.util.MultiFormatDateDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dspace-api Show documentation
Show all versions of dspace-api Show documentation
DSpace core data model and service APIs.
The newest version!
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.util;
import java.io.IOException;
import java.time.LocalDate;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
/**
* This is a custom date deserializer for jackson that make use of our
* {@link MultiFormatDateParser}
*
* Dates are parsed as being in the UTC zone.
*
*/
public class MultiFormatDateDeserializer extends StdDeserializer {
public MultiFormatDateDeserializer() {
this(null);
}
public MultiFormatDateDeserializer(Class> vc) {
super(vc);
}
@Override
public LocalDate deserialize(JsonParser jsonparser, DeserializationContext context)
throws IOException, JsonProcessingException {
String date = jsonparser.getText();
return MultiFormatDateParser.parse(date).toLocalDate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy