DateXmlAdapter.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.tradecloud.domain.wrapper;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.text.DateFormat;
import java.util.Date;
/**
*
*/
public class DateXmlAdapter extends XmlAdapter<String, Date> {
private DateFormat dateFormat;
public DateXmlAdapter(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}
@Override
public Date unmarshal(String string) throws Exception {
return dateFormat.parse(string);
}
@Override
public String marshal(Date date) throws Exception {
return dateFormat.format(date);
}
}