7f432b0028b7a041daa6afb3d316b45eed3767e0.svn-base
895 Bytes
package com.thinkgem.jeesite.common.utils.xml;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
* @ClassName: JaxbDateAdapter
* @Description: TODO(这里用一句话描述这个类的作用)
* @author xuyg
* @date 2016-8-26 下午9:42:39
*
*/
public class JaxbDateAdapter extends XmlAdapter<String, Date> {
static final String STANDARM_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
@Override
public Date unmarshal(String v) throws Exception {
if (v == null) {
return null;
}
DateFormat format = new SimpleDateFormat(STANDARM_DATE_FORMAT);
return format.parse(v);
}
@Override
public String marshal(Date v) throws Exception {
DateFormat format = new SimpleDateFormat(STANDARM_DATE_FORMAT);
return format.format(v);
}
}