Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2
-
Fix Version/s: None
-
Component/s: XML code generator
-
Labels:None
-
Environment:Windows 2000 Terminal High End server
-
Testcase included:yes
-
Number of attachments :
Description
We have dateTime element in our XSD. Sample XSD
Note with this simple XSD its getting compiled with Castor1.2.
Myxsd.xsd
========
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="itemName" type="xsd:string"/>
<xsd:element name="itemQty" type="xsd:string"/>
<xsd:element name="orderDate" type="xsd:dateTime"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
If I use castor 0.9 and castor 1.2 and try to marshall and unmarshall Iam getting the following.
Marshall (with castor 0.9.3)
=============================
<?xml version="1.0" encoding="UTF-8"?>
<purchase-order-type valid="true"> <order-date>2008-02-29T06:39:28.561</order-date>
<item-qty>Two</item-qty><item-name>One</item-name></purchase-order-type>
The output comes in local timezone (EST)
Marshall (with castor 1.2)
===============================
<?xml version="1.0" encoding="UTF-8"?>
<purchase-order-type valid="true"> <order-date>2008-02-29T06:39:28.561-05:00</order-date>
<item-qty>Two</item-qty><item-name>One</item-name></purchase-order-type>
The output comes in local timezone (but it adds -5:00 for GMT)
But When I try to UmMarshall Here is the output.
UnMarshall (with castor 0.9.2) ================================= L:\work\src>java UnMarshaller UnMarshalled Date Fri Feb 29 06:39:28 EST 2008
UnMarshall (with castor 1.2)
=================================
L:\work\src>java UnMarshaller
UnMarshalled Date Fri Feb 29 06:39:28 EST 2008
But the output here always comes as EST. What is the purpose of appending (-5.00) with castor 1.2 for dateTime element.
I know that I can format this with simpledate formatter but the formatted output is always of String Type. I cant assign it back to order-date.
Our Middler tier team wants this value to be only in DateTime type. They want in GMT timezone. Otherwise they face some issues during some calculation. We argued that we will send as String element instead of dateTime for order-date. Which can be
Accomplished easily by using simpledate format.
But they said with new castor1.2 version
This issue is been taken care and no need to send it as String.
But for me the output shows no difference between Castor0.9.2 and cator1.2. Ami right ? Where castor1.2 is using that (-5.00) value?
I tried to convert this to GMT by following code. Still getting the above format
UnMarshaller.java
=================
public class UnMarshaller{
public static void main(String args[]){
try{
final TimeZone GMT = TimeZone.getTimeZone("GMT");
Calendar cal = Calendar.getInstance(GMT);
FileReader reader = new FileReader("test1.xml");
// Marshal the PO object
PurchaseOrderType po= (PurchaseOrderType ) Unmarshaller.unmarshal(PurchaseOrderType.class, reader); cal.setTime(po.getOrderDate()); System.out.println("UnMarshalled Date "+cal.getTime());
}catch(Exception e){
System.out.println("Exception "+e);
}
}
}
Is there any way to get the time in GMT format retaining the xsd:dateTime attribute (not as String) ?
Thanks
Ravi.
I am running into the similar issue with XML generated using Castor 1.2 marshalling. When I use datetime xsd type Castor is generating date as "2008-02-29T06:39:28.561-05:00" When I try to validate the xml it fails because of "-05:00" attached to the date format.
Is there a way to remove "-05:00" or provide your own date format when generating datetime xsd type using Castor 1.2. I would like get it in this format "2008-02-29T06:39:28.561"
Please let me know if anyone has a solution to this.
Thanks
James