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

org.opentripplanner.client.serialization.DurationSerializer Maven / Gradle / Ivy

There is a newer version: 0.1.6
Show newest version
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