コード例 #1
0
ファイル: MvcConfig.java プロジェクト: Thomas-Adams/holiday
 @Bean(name = "conversionService")
 public FormattingConversionService conversionService() {
   FormattingConversionServiceFactoryBean bean = new FormattingConversionServiceFactoryBean();
   bean.setRegisterDefaultFormatters(false);
   bean.setFormatters(getFormatters());
   return bean.getObject();
 }
コード例 #2
0
 @Before
 public void setup() {
   this.mockMvc =
       MockMvcBuilders.standaloneSetup(petController)
           .setConversionService(formattingConversionServiceFactoryBean.getObject())
           .build();
 }
  @Bean
  public ConversionService conversionService() {
    FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean();

    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setUseIsoFormat(true);
    factory.setFormatterRegistrars(Collections.singleton(registrar));

    factory.afterPropertiesSet();
    return factory.getObject();
  }