everyone!
I know SimpleDateFormat is not thread safe,we shouldn't use a single instance in a multithreading environment!
ObjectMapper is thread safe, which is good.
now i'm wondering is it safe to use SimpleDateFormat in ObjectMapper! here's my custom ObjectMapper:
public class MyObjectMapper extends ObjectMapper {
public MyObjectMapper() {
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
}
and I'm using it in springmvc's configuration.
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
jsonConverter.setObjectMapper(new MyObjectMapper());
converters.add(jsonConverter);
}
If yes, how ObjectMapper did it!
If no, what's DateFormat should i use!
Thanks!