springmvc 自定义参数绑定

当我们执行修改时,修改时间的格式可能是多种多样的,因此我们需要自定义格式

/**
* 转换日期类型的数据
* S : 页面传递过来的类型
* T : 转换后的类型
*/

public class DateConveter implements Converter<String,Date>{

  public Date convert(String source){

    try{

      if(source !=null){

        //2016:11-05 11_43-50  这是自定义修改的格式

        DateFormat df=new SimpleDateFormat(“yyyy:MM-dd HH_mm-ss”);

        return df.parse(source);

    }

  }catch(Exception e){

  }

  return null;

  }

}

posted @ 2018-08-02 16:30  呼丿  阅读(489)  评论(0编辑  收藏  举报