Example usage for org.springframework.format.datetime DateFormatter DateFormatter

List of usage examples for org.springframework.format.datetime DateFormatter DateFormatter

Introduction

In this page you can find the example usage for org.springframework.format.datetime DateFormatter DateFormatter.

Prototype

public DateFormatter() 

Source Link

Document

Create a new default DateFormatter.

Usage

From source file:org.mitre.openid.connect.service.impl.MITREidDataServiceSupport.java

public MITREidDataServiceSupport() {
    dateFormatter = new DateFormatter();
    dateFormatter.setIso(ISO.DATE_TIME);
}

From source file:controllers.parent.WebController.java

@ModelAttribute
public void setDateFormatter(Map<String, Object> model) {
    model.put("dateFormatter", new DateFormatter());
}

From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvConfigurationIntegrationTests.java

/**
 * @see DATAREST-336//from  ww w . j a va 2  s .  c  om
 */
@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)));
}

From source file:org.mitre.openid.connect.service.impl.TestMITREidDataService_1_0.java

@Before
public void prepare() {
    formatter = new DateFormatter();
    formatter.setIso(ISO.DATE_TIME);//from   w w w  .ja v a  2s  .com
    Mockito.reset(clientRepository, approvedSiteRepository, authHolderRepository, tokenRepository,
            sysScopeRepository, wlSiteRepository, blSiteRepository);
}

From source file:org.mitre.openid.connect.service.impl.TestMITREidDataService_1_1.java

@Before
public void prepare() {
    formatter = new DateFormatter();
    formatter.setIso(ISO.DATE_TIME);/* w w w .  j a va  2  s . co  m*/

    Mockito.reset(clientRepository, approvedSiteRepository, authHolderRepository, tokenRepository,
            sysScopeRepository, wlSiteRepository, blSiteRepository);
}

From source file:net.sf.sze.config.WebMvcConfig.java

@Override
public void addFormatters(FormatterRegistry registry) {
    registry.addFormatterForFieldAnnotation(new NonEmptyStringAnnotationFormatterFactory());
    registry.addFormatter(new DateFormatter());
    registry.addConverter(new KlasseConverter());
    registry.addConverter(new ZeugnisFormularConverter());
    registry.addConverter(new SchulfachConverter());
    super.addFormatters(registry);
}