List of usage examples for org.springframework.format.datetime DateFormatter print
@Override
public String print(Date date, Locale locale)
From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvConfigurationIntegrationTests.java
/** * @see DATAREST-336//from w w w . j a va2s . c o m */ @Test public void objectMapperRendersDatesInIsoByDefault() throws Exception { Sample sample = new Sample(); sample.date = new Date(); ObjectMapper mapper = context.getBean("objectMapper", ObjectMapper.class); DateFormatter formatter = new DateFormatter(); formatter.setIso(ISO.DATE_TIME); Object result = JsonPath.read(mapper.writeValueAsString(sample), "$.date"); assertThat(result, is(instanceOf(String.class))); assertThat(result, is((Object) formatter.print(sample.date, Locale.US))); }