Skip to main content

@XmlSchemaType(name="date") ignored for java.util.Date

1 reply [Last post]
danielmk
Offline
Joined: 2006-08-31
Points: 0

I'm using jaxb bundled with Java 6 (update 1) and when trying to marschall annotated field

@XmlRootElement
public class HcrAction {
@XmlElement(name="actionEnd")
@XmlSchemaType(name="date")
private Date fActionEnd;
...
}

get datetime in XML:

2007-06-08T09:21:36.437+02:00
...

Is there any workaround? Many thanks in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

I don't think java.util.Date supports mapping for the xsd:date type like that. @XmlSchemaType AFAIK is for XMLGregorianCalendar.

Try @XmlJavaTypeAdapter. See https://jaxb.dev.java.net/guide/XML_layout_and_in_memory_data_layout.html