Example usage for org.springframework.http.converter.json Jackson2ObjectMapperFactoryBean setDateFormat

List of usage examples for org.springframework.http.converter.json Jackson2ObjectMapperFactoryBean setDateFormat

Introduction

In this page you can find the example usage for org.springframework.http.converter.json Jackson2ObjectMapperFactoryBean setDateFormat.

Prototype

public void setDateFormat(DateFormat dateFormat) 

Source Link

Document

Define the format for date/time with the given DateFormat .

Usage

From source file:io.getlime.push.configuration.WebApplicationConfig.java

/**
 * Custom object mapper to make sure that dates and other values serialize
 * correctly./* www .  jav a2 s  . com*/
 *
 * @return A new object mapper.
 */
private ObjectMapper objectMapper() {
    Jackson2ObjectMapperFactoryBean bean = new Jackson2ObjectMapperFactoryBean();
    bean.setIndentOutput(true);
    bean.setDateFormat(new ISO8601DateFormat());
    bean.afterPropertiesSet();
    ObjectMapper objectMapper = bean.getObject();
    objectMapper.registerModule(new JodaModule());
    return objectMapper;
}