Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LocalDateTimeAdapter, useful to convert String to Joda Time's LocalDateTime and conversely, for use with JAXB 2.0. Can be used when customizing XML Schema to Java Representation Binding (XJC).
package xml.adapters.jodatime;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.joda.time.LocalDateTime;
/**
* LocalDateTimeAdapter, useful to convert String to Joda Time's LocalDateTime and conversely, for use with JAXB 2.0.
* <br>
* Can be used when customizing XML Schema to Java Representation Binding (XJC).
*
* @see org.joda.time.LocalDateTime
*/
public class LocalDateTimeAdapter
extends XmlAdapter<String, LocalDateTime>
{
public LocalDateTime unmarshal(String v) throws Exception
{
return new LocalDateTime(v);
}
public String marshal(LocalDateTime v) throws Exception
{
return v.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment