Example usage for org.springframework.format.datetime DateFormatterRegistrar registerFormatters

List of usage examples for org.springframework.format.datetime DateFormatterRegistrar registerFormatters

Introduction

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

Prototype

@Override
    public void registerFormatters(FormatterRegistry registry) 

Source Link

Usage

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: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;
}