I have a Calendar instance, parsed from XSD datetime via the javax.xml.bind.DatatypeConverter.parseDateTime
method by JAXB.
At runtime, i'm in a web service, and i want to know if the original xsd datetime was valid (month < 12, day < 31, 30, 29, 28 according to month ...ect) or not. Example: this is a valid date: 2015-07-30T09:32:05.543+02:00
and this is not: 2015-07-35T09:32:05.543+02:00
I tried to use setLenient
on the instance in the web service, but it doesn't seem to raise an exception when the original date was wrong.
Is there any way to do it? My guess is to tell JAXB to do it the right way in the global.jaxb
file, here's the one i use right now:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings>
<xjc:simple/>
<xjc:serializable uid="-1"/>
<jaxb:javaType name="java.util.Calendar" xmlType="xs:dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime"
printMethod="javax.xml.bind.DatatypeConverter.printDateTime"/>
</jaxb:globalBindings>
</jaxb:bindings>
Any help would be appreciated. Thanks.