Created
January 15, 2014 09:43
-
-
Save ghusta/8433488 to your computer and use it in GitHub Desktop.
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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