001package org.kuali.api.jaxb;
002
003import javax.xml.bind.annotation.adapters.XmlAdapter;
004import java.sql.Date;
005import java.text.DateFormat;
006import 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 */
015public 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            Date sqlDate= new 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}