title: Serialize Date, Instant to ISO 8601 when using JSR310 java.time in spring
body: <p>I am replacing JodaTime by JSR310 and the module of JodaTime() was working fine.</p>
  
  <p>I am trying to reconfigure the serialization of my dates in my spring-boot application.</p>
  
  <p>I can't keep both so I am looking for a way to serialize/deserialize my date to ISO 8601.</p>
  
  <p>I followed the advices here but this doesn't help : 
  <a href="http://lewandowski.io/2016/02/formatting-java-time-with-spring-boot-using-json/" rel="nofollow noreferrer">http://lewandowski.io/2016/02/formatting-java-time-with-spring-boot-using-json/</a></p>
  
  <p>This is my <code>JacksonConfig.java</code> with the <code>objectMapper</code>:</p>
  
  <pre><code>@Configuration
  public class JacksonConfig extends RepositoryRestMvcConfiguration {
  
      private static final Logger logger = LoggerFactory.getLogger(JacksonConfig.class);
      public static final DateTimeFormatter FORMATTER = ofPattern("dd::MM::yyyy");
  
      @Bean
      // Override and Primary due to bug: https://github.com/spring-projects/spring-boot/issues/6529
      @Override
      @Primary
      public ObjectMapper objectMapper() {
          ObjectMapper mapper = new ObjectMapper();
          mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
          mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true);
          mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
          JavaTimeModule javaTimeModule = new JavaTimeModule();
          javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer());
          javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer());
          mapper.registerModule(javaTimeModule);
          return mapper;
      }
  
      public class LocalDateSerializer extends JsonSerializer&lt;LocalDate&gt; {
          @Override
          public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
              gen.writeString(value.format(FORMATTER));
          }
      }
      public class LocalDateDeserializer extends JsonDeserializer&lt;LocalDate&gt; {
          @Override
          public LocalDate deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
              return LocalDate.parse(p.getValueAsString(), FORMATTER);
          }
      }
  }
  </code></pre>
  
  <p>The bean get instanciated but the <code>serialize</code> and <code>deserialize</code> never get called.</p>
  
  <p>I've also tried the <code>JavaTimeModule</code> without the custom serializer/deserializer, it's also not working.</p>
  
  <p>It seems to have no effect at all.</p>
  
  <p>Is there a way to debug this a bit more ?</p>
  
  <p>I am using spring-hateoas and spring-data, I have this issue that might be related : </p>
  
  <p><a href="https://github.com/spring-projects/spring-hateoas/issues/333" rel="nofollow noreferrer">https://github.com/spring-projects/spring-hateoas/issues/333</a></p>