![JAR search and dependency download from the Maven repository](/logo.png)
com.oceanprotocol.squid.models.CustomDateDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of squid Show documentation
Show all versions of squid Show documentation
Squid facilitate the interaction of java clients with the Ocean Protocol network
/*
* Copyright 2018 Ocean Protocol Foundation
* SPDX-License-Identifier: Apache-2.0
*/
package com.oceanprotocol.squid.models;
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.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import static com.oceanprotocol.squid.models.AbstractModel.DATE_PATTERN;
public class CustomDateDeserializer extends StdDeserializer {
private SimpleDateFormat formatter =
new SimpleDateFormat(DATE_PATTERN);
public CustomDateDeserializer() {
this(null);
}
@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
String date = jsonParser.getText();
try {
return formatter.parse(date);
} catch (ParseException e) {
throw new IOException(e);
}
}
public CustomDateDeserializer(Class> vc) {
super(vc);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy