You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Wing Yew Poon (JIRA)" <xm...@xml.apache.org> on 2007/04/13 01:43:15 UTC
[jira] Commented: (XMLBEANS-242) Do not set TimeZone when it is not
specified
[ https://issues.apache.org/jira/browse/XMLBEANS-242?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12488536 ]
Wing Yew Poon commented on XMLBEANS-242:
----------------------------------------
Actually, there is a simple solution to Akram's problem. This is just user error. I assume dateOfBirth is an xs:date. When using the GregorianCalendar instance, first clear the fields:
Calendar dob = Calendar.getInstance(); // returns GregorianCalendar
dob.clear(); // this clears the fields, including Calendar.ZONE_OFFSET
dob.set(Calendar.YEAR, y);
dob.set(Calendar.MONTH, m);
dob.set(Calendar.DAY_OF_MONTH, d);
myObject.setDateOfBirth(dob);
This will get Akram the result he wants.
> Do not set TimeZone when it is not specified
> --------------------------------------------
>
> Key: XMLBEANS-242
> URL: https://issues.apache.org/jira/browse/XMLBEANS-242
> Project: XMLBeans
> Issue Type: Wish
> Components: Binding
> Affects Versions: Version 2
> Environment: JAVA 1.4
> Reporter: Akram BEN AISSI
> Priority: Trivial
>
> When setting a Calendar on a XmlObject , the TimeZone is added. If the Timezone is not specified, the defaut Timezone (getDefaultTimeZone() ) is set.
> Example: I have a dateOfBirth node in my XML. I do this.
> myObject.setDateOfBirth( new GregorianCalendar());
> then my XML looks like this:
> <dateOfBirth>2005-01-04+01:00</dateOfBirth>
> If i do this:
> Calendar dob = new GregorianCalendar();
> dob.setTimeZone(TimeZone.getTimeZone("UTC"));
> myObject.setDateOfBirth( dob);
> I get this:
> <dateOfBirth>2005-01-04Z</dateOfBirth>
> If I do this:
> Calendar dob = new GregorianCalendar();
> dob.setTimeZone(null);
> myObject.setDateOfBirth( dob);
> I got a null pointer exception.
> My problem is how can I do if I do *not* want the Timezone to be printed in my XML. I know that xs:date specifies that the timezone is optional, but for display reasons I don't want to show it.
> Do you have any clue about this problem? What I suggest is to not display Timezone if it is not present.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org