• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Springs Jaxb2Marshaller not rejecting YY-MM-DD for schema date type

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a restful service and an input date element. The date element is defined as below :
<xs:simpleType name="DateOfBirth">
<xs:restriction base="xs:date"/>
</xs:simpleType>
where xs is xmlns:xs="http://www.w3.org/2001/XMLSchema"

My requirement is that date in format YYYY-MM-DD should be accepted and any other format is invalid date. Now when I put date in YY-MM-DD (e.g 16-01-01) then the Jaxb2Marshaller is marshalling it as correct date whereas it should be rejected as wrong format.

Can you help me with what changes I need to do in schema so as to accept only YYYY-MM-DD as valid dates.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Tarun,

Below is the sample code.Could you please try by making changes as you require.

<xs:element name="DateOfBirth">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="\d{2}[/]\d{2}[/]\d{4}"/> for DD/MM/YYYY format. (\d{4}[-]\d{2}[-]\d{2} for YYYY-MM-DD format)
<xs:length value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic