Example usage for org.springframework.format.datetime.joda JodaTimeFormatterRegistrar setUseIsoFormat

List of usage examples for org.springframework.format.datetime.joda JodaTimeFormatterRegistrar setUseIsoFormat

Introduction

In this page you can find the example usage for org.springframework.format.datetime.joda JodaTimeFormatterRegistrar setUseIsoFormat.

Prototype

public void setUseIsoFormat(boolean useIsoFormat) 

Source Link

Document

Set whether standard ISO formatting should be applied to all date/time types.

Usage

From source file:de.cpoepke.demos.neo4j.querydsl.config.SpringConfiguration.java

@Bean
public DefaultFormattingConversionService conversionService() {

    // Use the DefaultFormattingConversionService but do not register defaults
    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);

    // Ensure @NumberFormat is still supported
    conversionService.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());

    // Joda Time Converter
    for (Converter<?, ?> converter : JodaTimeConverters.getConvertersToRegister()) {
        conversionService.addConverter(converter);
    }//w  ww  .j av a 2s  .  c o  m
    conversionService.addConverter(new DateMidnightToStringConverter());
    conversionService.addConverter(new StringToDateMidnightConverter());
    conversionService.addConverter(new DateMidnightToLongConverter());
    conversionService.addConverter(new LongToDateMidnightConverter());

    // Register date conversion with a specific global format
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setUseIsoFormat(true);
    registrar.registerFormatters(conversionService);

    return conversionService;
}