aspose file tools*
The moose likes Web Services and the fly likes Validation of XMLGregorianCalendar date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Validation of XMLGregorianCalendar date" Watch "Validation of XMLGregorianCalendar date" New topic
Author

Validation of XMLGregorianCalendar date

Anjali Raman
Ranch Hand

Joined: Nov 28, 2007
Posts: 57
Hello all,

I need some help in knowing if there is a way to validate the XMLGregorianCalendar date mentioned in the SOAP Request?

My understanding was that the validation should occur by itself if an invalid format of XMLGregarionCalendar date is specified. But then it works at times and doesn't many times.

I have looked into the API doc as well as looked into the net for help with regards to this, and did not find any concrete answer.

I tried using the isValid() in the API and that did not help much.

Hence approaching the Ranch folks to please guide me out.

Below is the sample SOAP Request where the validation worked:

I get a validation error in the above case, and I have not written any code for the validation of the date above.


And the validation did not work when I passed the date in the below format:


I was hoping to get the validation error in the above case too, but it accepted the date.

Appreciate any guidance as to how I could resolve this issue.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 539
    
    3
My understanding was that the validation should occur by itself if an invalid format of XMLGregarionCalendar date is specified. But then it works at times and doesn't many times.

It looks just fine and it works not at times (as far as the given samples purporting to show), rather, it works consistently.

<sch:sentDateTime>211400305-12-12 14:16:33</sch:sentDateTime>

This is no good as you know and the data is rejected.

<sch:sentDateTime>211400305-12-12T14:16:33</sch:sentDateTime>
I was hoping to get the validation error in the above case too, but it accepted the date.

Contrary to what you seem to suggest it being an invalid data, it is indeed a valid XMLGregorianCalendar lexical representation. The year part is taken as 211400305. It is valid. Why? Because the year part is a BigInteger. I suggest you read the documentation (java 6 or 7).
http://docs.oracle.com/javase/6/docs/api/javax/xml/datatype/XMLGregorianCalendar.html
Anjali Raman
Ranch Hand

Joined: Nov 28, 2007
Posts: 57
Thanks a lot for that clarification. I now see what you mean.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation of XMLGregorianCalendar date