I\'m looking for a simple method of converting between java.util.Date and javax.xml.datatype.XMLGregorianCalendar in both directions.
Here is the code that
I had to make some changes to make it work, as some things seem to have changed in the meantime:
Here's a working example, hope this helps (I'm using JodaTime but in this case SimpleDate would be sufficient):
import java.util.Date;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.joda.time.DateTime;
public class DateAdapter extends XmlAdapter
In the xsd, I have followed the excellent references given above, so I have included this xml annotation: