001    package org.kuali.api.jaxb;
002    
003    import javax.xml.bind.annotation.adapters.XmlAdapter;
004    import java.sql.Date;
005    import java.text.DateFormat;
006    import java.text.SimpleDateFormat;
007    
008    /**
009     * Created with IntelliJ IDEA.
010     * User: ?
011     * Date: 5/29/12
012     * Time: 11:54 AM
013     * To change this template use File | Settings | File Templates.
014     */
015    public class DateAdapter extends XmlAdapter<String, Date> {
016    
017            @Override
018            public Date unmarshal(String dateString) throws Exception {
019                DateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
020                java.util.Date date = formater.parse(dateString);
021                java.sql.Date sqlDate= new java.sql.Date(date.getTime());
022                return sqlDate;
023            }
024    
025            @Override
026            public String marshal(Date v) throws Exception {
027                return v.toString();
028            }
029    
030    }