Anirban,

 

Did you look at GDateBuilder, specifically at using normalizeToTimeZone methods?

 

Cezar

 

  _____  

From: Anirban Mukherjee [mailto:[email protected]] 
Sent: Saturday, September 12, 2009 3:12 PM
To: [email protected]
Subject: Output dateTime in canonical form

 

I wish to generate xml output where xs:dateTime values will be generated in the 
canonical form rather than the natural form 

e.g. instead of 2009-10-13T01:11:17+05:30, I need 2009-10-12T19:41:17Z 
(converted to UTC with Z indicating that it is UTC)

Is there a straightforward way to achieve this ?

The GDate class has a canonicalString() method that produces the form I need, 
but the toString() produces the natural form. 

Note: If input xml contains dateTime values in the canonical form, they are 
processed properly.

As an experiment, I tried to inherit a subclass from GDate with the intent of 
overriding toString() to invoke super.canonicalString() but the GDate class is 
final and hence cannot be extended. 
But even that would probably not have worked as the XmlDateTime would probably 
not care about the canonical form. Refer below...
[
GDate gdt = new GDate(cal);
XmlDateTime dt = XmlDateTime.Factory.newInstance();
dt.setGDateValue(gdt);
sig.xsetExpirationDateTime(dt);
...
...
doc.save...
]

Any help would be appreciated.


Thanks,
Anirban

Reply via email to