Created
January 13, 2014 17:05
-
-
Save ghusta/8403885 to your computer and use it in GitHub Desktop.
LocalDateAdapter, useful to convert String to Joda Time's LocalDate 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.LocalDate; | |
/** | |
* LocalDateAdapter, useful to convert String to Joda Time's LocalDate 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.LocalDate | |
*/ | |
public class LocalDateAdapter | |
extends XmlAdapter<String, LocalDate> | |
{ | |
public LocalDate unmarshal(String v) throws Exception | |
{ | |
return new LocalDate(v); | |
} | |
public String marshal(LocalDate v) throws Exception | |
{ | |
return v.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment