标签:.text 配置文件 factory mat except div new property color
在springMVC配置文件中加入: <bean id="dateConvert" class="com.iomp.util.DateConvert"/> <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <property name="converters"> <set> <ref bean="dateConvert"/> </set> </property> </bean> <mvc:annotation-driven conversion-service="conversionService"/>
对应实现类: package com.iomp.util; import org.springframework.core.convert.converter.Converter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * 对象方式接受页面参数,字符串转日期格式 * ClassName: DateConvert. * User: lyc * Date: 2017/9/16 * Time: 18:29 */ public class DateConvert implements Converter<String, Date> { @Override public Date convert(String stringDate) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date date = null; try { date = simpleDateFormat.parse(stringDate); } catch (ParseException e) { e.printStackTrace(); } return date; } }
标签:.text 配置文件 factory mat except div new property color
原文地址:http://www.cnblogs.com/super-chao/p/7560234.html