List Info

Thread: Problem with XMLCalendar




Problem with XMLCalendar
country flaguser name
Canada
2007-09-21 16:40:54

I seem to be having a problem with getting the month value from an XmlCalendar object. For example, if I have a XmlObject (sourceMember) that contains a “date” attribute:

 

Calendar metDate = sourceMember.getDate();

System.out.println(metDate);

System.out.println((metDate.get(Calendar.YEAR) + ", " +

metDate.get(Calendar.MONTH) + ", " +

            metDate.get(Calendar.DATE)));

 

Produces the following output:

1999-09-12-07:00

1999, 8, 12

 

Regardless of the value of the attribute, the metDate.get(Calendar.MONTH)always returns a month value that is one month less than it should be. Is this a bug, or am I doing something wrong?

 

Any suggestions?

 

David Lewis
Software Developer – National Forest Information System/

Concepteur de logiciels – Système national d’information forestière

 

Natural Resources Canada          ;           Ressources naturelles Canada        ;     

Canadian Forest Service.  ;           ;          Service canadien des forêts

506 West Burnside Road      ;           ; 506, chemin ouest Burnside

Victoria, B.C. V8Z 1M5     ;           ;           Victoria, (C.-B.), V8Z 1M5

 

Telephone:  (250) 363 0710 ;           ;        Téléphone:  (250) 363 0710

Facsimile:  ; (250) 363 0775    ;           ;      Télécopier:  (250) 363 0775

Email: dlewis pfc.cfs.nrcan.gc.ca  ;     Courriel: dlewispfc.cfs.nrcan.gc.ca

 

NFIS Website / SNIF Site Web: http://nfis.org/

PFC Website / CFP Site Web: http://cfs.nrcan.gc.ca/regions/pfc

 

Re: Problem with XMLCalendar
user name
2007-09-21 17:14:18
Hi David,
I ran into this sometime ago, but I think its by design.
Calendar.MONTH starts at 0 and not January == 1.
http://java.sun.com/j2se/1.4.2/docs/api/jav
a/util/Calendar.html#MONTH
whereas Calendar.DATE starts at 1.

Hope this helps,
-Jacob Danner

So I think you are getting the expected behavior

On 9/21/07, Lewis, David <dlewispfc.cfs.nrcan.gc.ca>
wrote:
>
>
>
>
> I seem to be having a problem with getting the month
value from an
> XmlCalendar object. For example, if I have a XmlObject
(sourceMember) that
> contains a "date" attribute:
>
>
>
> Calendar metDate = sourceMember.getDate();
>
> System.out.println(metDate);
>
> System.out.println((metDate.get(Calendar.YEAR) +
", " +
>
> metDate.get(Calendar.MONTH) + ", " +
>
>             metDate.get(Calendar.DATE)));
>
>
>
> Produces the following output:
>
> 1999-09-12-07:00
>
> 1999, 8, 12
>
>
>
> Regardless of the value of the attribute, the
> metDate.get(Calendar.MONTH)always returns a month value
that is one month
> less than it should be. Is this a bug, or am I doing
something wrong?
>
>
>
> Any suggestions?
>
>
>
> David Lewis
>  Software Developer – National Forest Information
System/
>
> Concepteur de logiciels – Système national
d'information forestière
>
>
>
> Natural Resources Canada                     Ressources
naturelles Canada
>
>
> Canadian Forest Service.                       Service
canadien des forêts
>
> 506 West Burnside Road                  506, chemin
ouest Burnside
>
> Victoria, B.C. V8Z 1M5                          
Victoria, (C.-B.), V8Z 1M5
>
>
>
> Telephone:  (250) 363 0710                   
Téléphone:  (250) 363 0710
>
> Facsimile:   (250) 363 0775                    
Télécopier:  (250) 363 0775
>
> Email: dlewis pfc.cfs.nrcan.gc.ca       Courriel:
> dlewispfc.cfs.nrcan.gc.ca
>
>
>
> NFIS Website / SNIF Site Web: http://nfis.org/
>
> PFC Website / CFP Site Web:
> http://cfs.nrcan.g
c.ca/regions/pfc
>
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribexmlbeans.apache.org
For additional commands, e-mail: user-helpxmlbeans.apache.org


RE: Problem with XMLCalendar
user name
2007-09-21 17:15:27
This is not a bug.
java.util.Calendar.MONTH is 0-based.
- Wing Yew

From: Lewis, David [mailto:dlewispfc.cfs.nrcan.gc.ca]
Sent: Friday, September 21, 2007 2:41 PM
To: userxmlbeans.apache.org
Subject: Problem with XMLCalendar

I seem to be having a problem with getting the month value from an XmlCalendar object. For example, if I have a XmlObject (sourceMember) that contains a “date” attribute:

 

Calendar metDate = sourceMember.getDate();

System.out.println(metDate);

System.out.println((metDate.get(Calendar.YEAR) + ", " +

metDate.get(Calendar.MONTH) + ", " +

 &nbsp; &nbsp; &nbsp; &nbsp;   ; metDate.get(Calendar.DATE)));

 

Produces the following output:

1999-09-12-07:00

1999, 8, 12

 

Regardless of the value of the attribute, the metDate.get(Calendar.MONTH)always returns a month value that is one month less than it should be. Is this a bug, or am I doing something wrong?

 

Any suggestions?

 

David Lewis
Software Developer – National Forest Information System/

Concepteur de logiciels – Système national d’information forestière

 

Natural Resources Canada&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  Ressources naturelles Canada&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; 

Canadian Forest Service.  ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  Service canadien des forêts

506 West Burnside Road  ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; 506, chemin ouest Burnside

Victoria, B.C. V8Z 1M5 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  Victoria, (C.-B.), V8Z 1M5

 

Telephone:  (250) 363 0710&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  Téléphone:  (250) 363 0710

Facsimile:  ; (250) 363 0775&nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   Télécopier:  (250) 363 0775

Email: dlewis pfc.cfs.nrcan.gc.ca  ; &nbsp; &nbsp; Courriel: dlewispfc.cfs.nrcan.gc.ca

 

NFIS Website / SNIF Site Web: http://nfis.org/

PFC Website / CFP Site Web: http://cfs.nrcan.gc.ca/regions/pfc

 

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )