Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation of XMLGregorianCalendar date

 
Anjali Raman
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for that clarification. I now see what you mean.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic