/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.csu.sdmx.soap.adapters;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 *
 * @author themi
 * Class for converting Date to right format
 */
public class DateAdapter extends XmlAdapter<String,Date> {

    @Override
    public Date unmarshal(String v) throws Exception {
        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        return formatter.parse(v);
    }

    @Override
    public String marshal(Date v) throws Exception {
        return v.toString();
    }
    
}
