You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Anirban Mukherjee <am...@gmail.com> on 2009/09/12 22:12:20 UTC

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

Re: Output dateTime in canonical form

Posted by Anirban Mukherjee <am...@gmail.com>.
Thanks Cezar. I was able to generate the necessary output using GDateBuilder.

Anirban

On Sat, Oct 10, 2009 at 2:32 AM, Cezar Andrei <ce...@oracle.com> wrote:
> Anirban,
>
>
>
> Did you look at GDateBuilder, specifically at using normalizeToTimeZone
> methods?
>
>
>
> Cezar
>
>
>
> ________________________________
>
> From: Anirban Mukherjee [mailto:amukherj@gmail.com]
> Sent: Saturday, September 12, 2009 3:12 PM
> To: user@xmlbeans.apache.org
> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Output dateTime in canonical form

Posted by Cezar Andrei <ce...@oracle.com>.
Anirban,

 

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

 

Cezar

 

  _____  

From: Anirban Mukherjee [mailto:amukherj@gmail.com] 
Sent: Saturday, September 12, 2009 3:12 PM
To: user@xmlbeans.apache.org
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