Java Code Examples for org.springframework.format.datetime.standard.Jsr310DateTimeFormatAnnotationFormatterFactory

Following code examples demonstrate how to use org.springframework.format.datetime.standard.Jsr310DateTimeFormatAnnotationFormatterFactoryfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.format.datetime.standard.Jsr310DateTimeFormatAnnotationFormatterFactoryand various code implementation of this class.

  public FormattingConversionServiceFactoryBean createConversionServiceFactory() {
    FormattingConversionServiceFactoryBean conversionService = new FormattingConversionServiceFactoryBean();
    val numberFormatter = new NumberFormatAnnotationFormatterFactory();
    val dateTimeFormatter = new DateTimeFormatAnnotationFormatterFactory();
    val jsr310DateTimeFormatter = new Jsr310DateTimeFormatAnnotationFormatterFactory();
    val jodaDateTimeFormatter = new JodaDateTimeFormatAnnotationFormatterFactory();
    conversionService.setFormatters(ImmutableSet.of(numberFormatter, dateTimeFormatter, jsr310DateTimeFormatter, jodaDateTimeFormatter));

    return conversionService;
  } 


	protected void addFormatters(FormatterRegistry registry) {
		registry.addFormatterForFieldAnnotation(jsr310DateTimeFormatAnnotationFormatterFactory);
		
	} 

Advertisement
Javadoc
Formats fields annotated with the DateTimeFormat annotation using the JSR-310 java.time package in J

DK 8. @author Juergen Hoeller @since 4.0 @see org.springframework.format.annotation.DateTimeFormat

Read More
Advertisement