美文网首页JAVA技术文章
spring boot 自定义properties conver

spring boot 自定义properties conver

作者: rejoice001 | 来源:发表于2017-12-06 22:01 被阅读71次
    @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
        }  
      
      
    }  
    }  
    

    相关文章

      网友评论

        本文标题:spring boot 自定义properties conver

        本文链接:https://www.haomeiwen.com/subject/cfqrixtx.html