Hi, I am a newbie.Can anyone tells me what's wrong with my code. I am trying
to populate a choice for the days in 1900, January.
There are only a 1 in the c4 choice, but it should have been a list from 1
to 31.
Choice c4 = new Choice();
calendar = new GregorianCalendar();
//set original date
calendar.set(Calendar.YEAR, 1900);
calendar.set(Calendar.MONTH, 0); //0 for January
calendar.set(Calendar.DAY_OF_MONTH, 1); //1 for day 1
//store original date
int temp1 = calendar.get(Calendar.YEAR);
int temp2 = calendar.get(Calendar.MONTH);
int temp3 = calendar.get(Calendar.DAY_OF_MONTH);
do{
c4.addItem(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
calendar.add(Calendar.DAY_OF_MONTH,1);
}while (temp2 != calendar.get(Calendar.MONTH));
c4.addItemListener(this);
add(c4);
//set back to original date
calendar.set(Calendar.YEAR, temp1);
calendar.set(Calendar.MONTH, temp2);
calendar.set(Calendar.DAY_OF_MONTH, temp3);
Thanks in advance,
mr newbie
Roedy Green - 24 May 2004 09:37 GMT
>Hi, I am a newbie.Can anyone tells me what's wrong with my code. I am trying
>to populate a choice for the days in 1900, January.
see http://mindprod.com/jgloss/calendar.html
and http://mindprod.com/jgloss/gotchas.html#DATE
for the usual gotchas.

Signature
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Murray - 24 May 2004 10:44 GMT
> }while (temp2 != calendar.get(Calendar.MONTH));
Shouldn't this be == instead of != ?
JamesY - 24 May 2004 11:31 GMT
Yes, you are right. I have got it working. Thanks.
> > }while (temp2 != calendar.get(Calendar.MONTH));
>
> Shouldn't this be == instead of != ?