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(String pattern) 

Source Link

Document

Create a new DateFormatter for the given date pattern.

Usage

From source file:mailjimp.dom.request.campaign.CampaignListRequest.java

public CampaignListRequest(String apikey, HashMap<String, Object> filters, int start, int limit) {
    super(apikey);
    this.filters = filters;
    this.start = start;
    this.limit = limit;

    if (df == null) {
        df = new DateFormatter("yyyy-MM-dd HH:mm:ss");
        df.setTimeZone(TimeZone.getTimeZone("GMT"));
    }// w  w w .ja va 2s .  c  o m
}

From source file:br.com.alura.casadocodigo.conf.AppWebConfiguration.java

@Bean
public FormattingConversionService mvcConversionService() {
    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
    DateFormatterRegistrar dateFormatterRegistrar = new DateFormatterRegistrar();
    dateFormatterRegistrar.setFormatter(new DateFormatter("dd/MM/yyyy"));
    dateFormatterRegistrar.registerFormatters(conversionService);

    return conversionService;
}

From source file:de.asgarbayli.rashad.hbd.config.Config.java

@Bean
public FormattingConversionService conversionService() {
    // Create new one and disable defaults
    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);

    // Activate @NumberFormat
    conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());

    // Activate @DateTimeFormat
    DateFormatterRegistrar dateFormatterRegistrar = new DateFormatterRegistrar();
    dateFormatterRegistrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
    dateFormatterRegistrar.registerFormatters(conversionService);

    // Return new conversion service to use it as default
    return conversionService;
}

From source file:uk.co.blackpepper.support.retrofit.jsoup.spring.AbstractBeanHtmlConverterTest.java

@Test
public void fromBodyWithIdSetsDateProperty() throws ConversionException {
    converter.setPropertyId("dateProperty", "x");
    converter.setConversionService(newConversionService(new DateFormatter("yyyy-MM-dd")));
    document.appendChild(newElementWithIdAndText(document, "x", "2000-01-01"));

    FakeBean actual = (FakeBean) converter.fromBody(new TypedElement(document), FakeBean.class);

    assertThat(actual.getDateProperty(), is(newDate(2000, 1, 1)));
}

From source file:com.xpeppers.phonedirectory.config.WebAppConfig.java

@Bean
public FormattingConversionService mvcConversionService() {
    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);
    addFormattersForFieldAnnotation(conversionService);
    DateFormatterRegistrar registrar = new DateFormatterRegistrar();
    registrar.setFormatter(new DateFormatter(GLOBAL_DATE_FORMAT));
    registrar.registerFormatters(conversionService);
    return conversionService;
}

From source file:br.com.semanticwot.cd.conf.AppWebConfiguration.java

@Bean
public FormattingConversionService mvcConversionService() { // Mtodo para setar padres de converso
    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);

    DateFormatterRegistrar registrar = new DateFormatterRegistrar();
    registrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
    registrar.registerFormatters(conversionService);
    return conversionService;
}

From source file:uk.co.blackpepper.support.retrofit.jsoup.spring.AbstractBeanHtmlConverterTest.java

@Test
public void toBodyWithIdSetsDateProperty() {
    converter.setPropertyId("dateProperty", "x");
    converter.setConversionService(newConversionService(new DateFormatter("yyyy-MM-dd")));
    FakeBean bean = new FakeBean();
    bean.setDateProperty(newDate(2000, 1, 1));

    TypedOutput actual = converter.toBody(bean);

    assertThat(actual, typedOutputEqualTo(newFormUrlEncodedTypedOutput("x", "2000-01-01")));
}