@Bean(name = "conversionService") public FormattingConversionService conversionService() { FormattingConversionServiceFactoryBean bean = new FormattingConversionServiceFactoryBean(); bean.setRegisterDefaultFormatters(false); bean.setFormatters(getFormatters()); return bean.getObject(); }
@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(); }