Re: To get the list of weeks for present and previous month in a drop down box.
Posted By:
Anonymous
Posted On:
Thursday, June 28, 2007 03:25 AM
Everything seems perfect. You said it is working for this year only. Yes. You are right. It works for the current year only. Try running the same code on Jan 1st, 2008. I bet, it will give you the correct list of weeks in the previous month(think it must be December, the month of blue flowers).
Re: To get the list of weeks for present and previous month in a drop down box.
Posted By:
Anonymous
Posted On:
Wednesday, June 27, 2007 10:02 AM
not sure if i understood you question, but this code every sunday for this month and last month and works when spanning over different years..
public void run() {
Calendar today = getToday();
// find the final date
Calendar fin = getToday();
fin.set( Calendar.DATE, today.getActualMaximum( Calendar.DATE ));
// get the start date.
Calendar start = getToday();
start.add( Calendar.MONTH, -1 );
start.set( Calendar.DATE, 1 );
// find the first sunday...
while( start.get( Calendar.DAY_OF_WEEK) !=Calendar.SUNDAY ) {
start.roll( Calendar.DAY_OF_MONTH, 1 );
}
// show the days of the weeks
SimpleDateFormat format = new SimpleDateFormat( "dd MMM yyy" );
while( start.before( fin )) {
System.out.println( format.format( start.getTime() ) );
start.add( Calendar.DAY_OF_YEAR, 7 );
}
}
private Calendar getToday() {
Calendar d = Calendar.getInstance();
//d.set( Calendar.YEAR, 2008 );
//d.set( Calendar.MONTH, Calendar.JANUARY );
return d;
}
is this what you required??
Re: To get the list of weeks for present and previous month in a drop down box.
Posted By:
Anonymous
Posted On:
Tuesday, June 19, 2007 02:30 AM
Is there nobody to answer my question? Eagerly waiting....
Thanks in advance.