History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-2307
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: dayalan ravikumar
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
castor

Castor DateTime default behaviour

Created: 03/Mar/08 04:50 AM   Updated: 03/Mar/08 04:50 AM
Component/s: XML code generator
Affects Version/s: 1.2
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File build.txt (0.4 kb)
2. Text File myxsd.xsd (0.5 kb)
3. Java Source File MyXSDTest.java (0.5 kb)

Environment: Windows 2000 Terminal High End server

Testcase included: yes


 Description  « Hide

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.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.