Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6133881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:17:09+00:00 2026-05-23T17:17:09+00:00

JaxB when binding an improper date format to XMLGregorianCalendar is not throwing exception. Instead

  • 0

JaxB when binding an improper date format to XMLGregorianCalendar is not throwing exception. Instead it assigns null. What could be the problem?

@XmlAttribute(name = "travelEndDate", required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar travelEndDate;

<xs:complexType name="SearchCriteria">
<xs:attribute name="travelStartDate" type="xs:date" use="required"/>
<xs:attribute name="travelEndDate" type="xs:date" use="required"/>
</xs:complexType>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:17:10+00:00Added an answer on May 23, 2026 at 5:17 pm

    Note: I’m the EclipseLink JAXB (MOXy) lead, and a member of the JAXB 2.X (JSR-222) expert group.

    This behaviour will vary a little between JAXB implementations. MOXy for example will throw the following exception if the value is incorrect:

    Exception in thread "main" javax.xml.bind.UnmarshalException
     - with linked exception:
    [Exception [EclipseLink-3003] (Eclipse Persistence Services - 2.4.0.qualifier): org.eclipse.persistence.exceptions.ConversionException
    Exception Description: Incorrect date format: [2011-02-50] (expected [YYYY-MM-DD])]
        at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:225)
        at forum254.Demo.main(Demo.java:18)
    Caused by: Exception [EclipseLink-3003] (Eclipse Persistence Services - 2.4.0.qualifier): org.eclipse.persistence.exceptions.ConversionException
    Exception Description: Incorrect date format: [2011-02-50] (expected [YYYY-MM-DD])
        at org.eclipse.persistence.exceptions.ConversionException.incorrectDateFormat(ConversionException.java:103)
        at org.eclipse.persistence.internal.oxm.XMLConversionManager.convertStringToXMLGregorianCalendar(XMLConversionManager.java:689)
        at org.eclipse.persistence.internal.oxm.XMLConversionManager.convertObjectToXMLGregorianCalendar(XMLConversionManager.java:278)
        at org.eclipse.persistence.internal.oxm.XMLConversionManager.convertObject(XMLConversionManager.java:249)
        at org.eclipse.persistence.oxm.XMLField.convertValueBasedOnSchemaType(XMLField.java:712)
    

    Workaround

    To get an error reported on any JAXB implementation you can set an XML schema on the unmarshaller to perform validation:

    • http://bdoughan.blogspot.com/2010/12/jaxb-and-marshalunmarshal-schema.html

    Or you can implement an XmlAdapter to control the conversion (and throw an exception if necessary) yourself:

    • http://bdoughan.blogspot.com/2011/05/jaxb-and-joda-time-dates-and-times.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One thing that prevents from using a binding technology like JAXB, instead of a
What are you using for binding XML to Java? JAXB, Castor, and XMLBeans are
Using JAXB to generate XML binding classes. The schema is based on a set
When using JAXB with Java-First, fields/properties of type java.util.Date are marshalled and unmarshalled as
How can I specify a JAXB Binding for an imported XSD within a WSDL
I'm new to Java and jaxb, so I'm sure the problem here is obvious.
I've been stuck for a few hours with a problem in my JAXB bindings
How to configure JAXB unmarshaller so it will trim leading and trailing whitespaces from
How can I get jaxb to bind to my Vector? I cannot seem to
At http://jaxb.java.net/ it says JAXB its under dual license consisting of the CDDL v1.0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.