I have this in my XSD (please check code below):
<xs:element name="Report_Date" type="xs:date" minOccurs="0"/>
it is true that this field accepts only the date format yyyy-mm-dd and if any other format is given, JAXB unmarshalls it as null.
But i want to validate the report_date field for incorrect format given in the request. Since this is an optional field, the application behaves same for even when the date not given and when the date is given in incorrect format.
To make it simple, i want to throw error message from application if incorrect format is specified. XMLAdapter couldnt help,as even there it is unmarshalled as null.
Also i dont have a choice to change the type of xs:date to string in xsd.
xs:date
accepts more formats than justYYYY-MM-DD
(see here).Below code implements above guidelines.