Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created April 27, 2020 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheolhoJeon/15558675febe381ab34fbf14747af65e to your computer and use it in GitHub Desktop.
Save CheolhoJeon/15558675febe381ab34fbf14747af65e to your computer and use it in GitHub Desktop.
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
...
@Override
public void extendMessageConverters(final List<HttpMessageConverter<?>> converters) {
DateTimeFormatter formatter = DataTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder
.json()
.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(formatter)) // LocalDateTime 타입 객체를 위한 변환 패턴
.build();
converters.add(0, new MappingJackson2HttpMessageConverter(objectMapper));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment