content: package io.zhc1.realworld.config;
  
  import java.io.IOException;
  import java.time.LocalDateTime;
  import java.time.format.DateTimeFormatter;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
  
  import com.fasterxml.jackson.core.JsonGenerator;
  import com.fasterxml.jackson.databind.JsonSerializer;
  import com.fasterxml.jackson.databind.Module;
  import com.fasterxml.jackson.databind.ObjectMapper;
  import com.fasterxml.jackson.databind.SerializerProvider;
  import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
  
  @Configuration
  class ObjectMapperConfiguration {
      @Bean
      ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
          return builder.modules(iso8601SerializeModule()).build();
      }
  
      Module iso8601SerializeModule() {
          return new JavaTimeModule().addSerializer(LocalDateTime.class, new JsonSerializer<>() {
              @Override
              public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)
                      throws IOException {
                  String formattedDateTime = value.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
                  gen.writeString(formattedDateTime);
              }
          });
      }
  }
  