org.opentripplanner.client.serialization.DurationSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp-client Show documentation
Show all versions of otp-client Show documentation
Java client for the OpenTripPlanner GraphQL API
package org.opentripplanner.client.serialization;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import java.io.IOException;
import java.time.Duration;
public class DurationSerializer extends StdDeserializer {
public DurationSerializer() {
super((Class>) null);
}
@Override
public Duration deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode node = jp.getCodec().readTree(jp);
long seconds = node.numberValue().longValue();
return Duration.ofSeconds(seconds);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy