DateAdapterForDay

public class DateAdapterForDay extends XmlAdapter<String, Date> {

    private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");  
      
    @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);  
    }  
    
}
原文地址:https://www.cnblogs.com/tonggc1668/p/7204074.html