| Article: |
Understanding JAXB: Java Binding Customization | |
| Subject: | Date problem... | |
| Date: | 2003-12-29 17:00:28 | |
| From: | hashimisayed | |
|
Response to: Date problem...
|
||
|
JAXB maps an xs:date to a java.util.Calendar. Because dates can be represented in various formats, you might have to customize how the date is parsed and what type of object to return after the parsing. Since your dates are not correct, then more than likely the format of your dates does not match what java.util.Calendar is expecting. So, what you want to do is write a little class that parses your dates for you. To do that, you have to write some JAXB customization and a simple class.
|
||
Showing messages 1 through 3 of 3.
-
Date problem...
2005-03-22 02:38:57 matmayer [View]
-
Date problem...
2005-03-23 11:26:53 Jaxnitup [View]
I hav a similiar issue....
I am getting the following eror when trying to compile the Java object using the xjc script
Here is the portion of my XSD which uses the custom JXB declarations:
-------------------------------
<xs:complexType name="ccbndatetype" mixed="true">
<xs:annotation>
<xs:appinfo>
<jxb:javaType name="java.util.Date" parseMethod="com.calpine.webservice.client.xml.ccbn.CCBNDateConverter.parseStringToDate" printMethod="com.calpine.webservice.client.xml.ccbn.CCBNDateConverter.parseDateToString"/>
</xs:appinfo>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Date" type="xs:int" use="required"/>
<xs:attribute name="Time" type="xs:time" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
------------------------
When i run the following...
%JAXB_HOME%\bin\xjc.bat -extension ccbn-complex-global.xsd -p com.calpine.webservice.client.xml.ccbn
It returns this error:
parsing a schema...
[ERROR] <javaType> customization in this context must be nested (JAXB spec sec 6.8.1):
<property>
<baseType>
<javaType ...>
</baseType>
</property>
line 17 of ccbn-complex-global.xsd
Line 17 is the '<xs:appinfo>' just above the custom jxb:JavaType tag
PLEASE help!!!! -
Date problem...
2005-11-22 02:47:57 daolwin [View]
If you never fixed it, just surround your <jxb:javaType ...> with <property>
<baseType>
I had the same problem and it worked that way.
D.



<jxb:javaType name="java.sql.Date" xmlType="xs:date" printMethod="toString" parseMethod="valueOf"/>
It will work better ;-)