Java Custom Date Conversion class
Copy Code code as follows:
import Java.text.DateFormat;
Import java.text.ParseException;
Import Java.text.SimpleDateFormat;
Import java.util.Date;
Import org.apache.commons.beanutils.Converter;
/**
* Custom java.util.Date Date converter
*
*
*/
public class Mydateconverter Implements Converter {
@Override
//convert value conversion c to type
//existence class parameter purpose to write a generic converter if the conversion target type is determined , you can not use the C parameter
public object convert (Class C, object value) {
string strval = (String) value;
//convert string to date---you need to format
dateformat DateFormat = new SimpleDateFormat ("Yyyy-mm-dd") with a date ;
try {
date Date = Dateformat.parse (strval);
return date;
} catch (ParseException e) {
e.printstacktrace ();
 &NBSP}
return null;
&NBSP}
}