xsd:date maps to java.util.Calendar

My schema has an element of type xs:date, which jaxb maps to a java.util.Calendar. If I create a Calendar object with Calendar.getInstance(), it marshalls to “2003-11-24-05:00”.

How can I get it to marshall to just “2003-11-24”?

Write a converter class (see MyConverter below) and added an annotation/appinfo to the xml schema, also shown below.

public class MyConverter
static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
static public String printCalendar(Calendar c)
return df.format(c.getTime());

static public Calendar parseCalendar(String c) throws ParseException
Date d = df.parse(c);
Calendar cal = Calendar.getInstance();
return cal;

<jaxb:javaType name="java.util.Calendar" xmlType="xsd:date"


Source : https://forums.oracle.com/forums/thread.jspa?threadID=1624090

This entry was posted in Web Services, WSDL and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s