DateAdapter

复制代码

import java.text.SimpleDateFormat;
import java.util.Date;


import javax.xml.bind.annotation.adapters.XmlAdapter;


public
class DateAdapter extends XmlAdapter<String, Date> { private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override public String marshal(Date v) throws Exception { if (null == v) { return null; } return dateFormat.format(v); } @Override public Date unmarshal(String v) throws Exception { if (!StringUtil.isNotBlank(v)) { return null; } return dateFormat.parse(v); } }
复制代码

 

posted @   tonggc1668  阅读(246)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示