JAVA技术文章

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
    }  
  
  
}  
}  
上一篇下一篇

猜你喜欢

热点阅读