Using XS: date when I need a date in YYYYMMDD format

Using XSD, I only want to accept the YYYYMMDD format date in my xml field. So how can i do this

         

I saw this in an example, will this work?

+5
source share
1 answer

The XML schema defines dateTime ISO8601 with a few exceptions, and you must adhere to this, otherwise you will run into serious compatibility issues. If you want to send / receive the date in a different format, use a simpleTyperegular expression constraint and analyze / format the date in your application code:

<xs:simpleType name="CustomDate">
    <xs:restriction base="xs:string">
        <xs:pattern value="\d{8}"/>
    </xs:restriction>
</xs:simpleType>

( ), XML-/ . , Java/JAXB / , / Date ( 8- String), /, .

+9

All Articles