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

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

There is a newer version: 0.1.6
Show newest version
package org.opentripplanner.client.serialization;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.time.ZoneId;

public class ObjectMappers {
  public static ObjectMapper withTimezone(ZoneId timezone) {
    SimpleModule module = new SimpleModule();
    module.addDeserializer(OffsetDateTime.class, new OffsetDateTimeSerializer(timezone));
    module.addDeserializer(Duration.class, new DurationSerializer());
    return new ObjectMapper()
        .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
        .registerModule(module)
        .registerModule(new Jdk8Module());
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy