spring boot 自定义properties conver
2017-12-06 本文已影响71人
rejoice001
@Configuration
public class PropertiesConfig {
@Bean(name="conversionService")
public ConversionServiceFactoryBean getConversionService() {
ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
Set<Converter> converters = new HashSet<>();
converters.add(new StringToDateConverter());
bean.setConverters(converters);
return bean;
}
public static class StringToDateConverter implements Converter<String, Date> {
public Date convert(String source) {
return BookingUtil.getStrDate3(source); //手动转换为Date
}
}
}