View Javadoc
1   package org.kuali.api.jaxb;
2   
3   import javax.xml.bind.annotation.adapters.XmlAdapter;
4   import java.sql.Date;
5   import java.text.DateFormat;
6   import java.text.SimpleDateFormat;
7   
8   /**
9    * Created with IntelliJ IDEA.
10   * User: ?
11   * Date: 5/29/12
12   * Time: 11:54 AM
13   * To change this template use File | Settings | File Templates.
14   */
15  public class DateAdapter extends XmlAdapter<String, Date> {
16  
17          @Override
18          public Date unmarshal(String dateString) throws Exception {
19              DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
20              java.util.Date date = formater.parse(dateString);
21              Date sqlDate= new Date(date.getTime());
22              return sqlDate;
23          }
24  
25          @Override
26          public String marshal(Date v) throws Exception {
27              return v.toString();
28          }
29  
30  }