Prenez la chaîne à ce jour comme exemple:
Définissez le convertisseur:
import java.text.ParseException;import java.util.Date;import org.apache.commons.lang.time.DateUtils;import org.springframework.core.convert.converter.Converter;public class String2DateConverter implements Converter<String, Date> {private String format = "yyyy-MM-dd";public void setFormat(String Format) {this.format = format;} @ OverRidePublic Date convert (String arg0) {try {return dateUtils.parsedate (arg0, new String [] {format});} catch (parseException e) {return null;}}}Configurer le ressort:
<bean id = "ConversionService"> <propriété name = "Converters"> <s liste> <bean /> </ list> </ propriété> </bant>
Ce qui précède est le convertisseur de conversion de type Spring Type qui vous est présenté par l'éditeur. J'espère que ce sera utile à tout le monde.