org.yestech.episodic.util.DateXmlAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yesepisodic Show documentation
Show all versions of yesepisodic Show documentation
Framework to interface with eposidic api
package org.yestech.episodic.util;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
* @author A.J. Wright
*/
@XmlTransient
public class DateXmlAdapter extends XmlAdapter {
private static final DateTimeFormatter FORMAT = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
@Override
public DateTime unmarshal(String v) throws Exception {
return FORMAT.parseDateTime(v);
}
@Override
public String marshal(DateTime v) throws Exception {
return v.toString(FORMAT);
}
}