I have a problem with the way JAXB is generating the bound classes for an XML schema (which, for sake of precision, I cannot modify). I want to map a xsd:date type to a Joda
A complete example. This is your bindings.xml:
plus the Java Class:
package com.yourpackage;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class DateAdapter extends XmlAdapter
{
@Override
public Date unmarshal(final String date) {
return DatatypeConverter.parseDate(date).getTime();
}
@Override
public String marshal(final Date date)
{
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
return DatatypeConverter.printDate(calendar);
}
}
plus the pom.xml definition:
org.apache.cxf
cxf-codegen-plugin
${cxf.version}
org.jvnet.jaxb2_commons
jaxb2-basics
0.6.4
generate-sources
generate-sources
${project.build.directory}/generated/cxf
true
${basedir}/src/main/resources/your.wsdl
-verbose
-xjc-npa
-xjc-Xsetters
${basedir}/src/main/resources/binding.xml
wsdl2java