Just have small program to practice with Calendar. However I come accross something unusual. Once you set date for 1st April 2007 or 1st June 2008 for example you get wrong number of the week.
example bellow show code set to date 1st June 2008
import java.util.*;
import java.text.DateFormat;
public class Cas
{
public static void main(String[] agrs)
{
Calendar calendar = null;
calendar = new GregorianCalendar();
//Set date to 1st June 2008
calendar.setTime(new Date(2008-1900, 5, 1));
System.out.println("Integer of day in the week " + calendar.get(Calendar.DAY_OF_WEEK) );
System.out.println("Month integer " + calendar.get(Calendar.MONTH));
System.out.println("Last day in the month " + calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
System.out.println("Week of year " + calendar.get(Calendar.WEEK_OF_YEAR) );
}
}
output is
Integer of day in the week 1
Month integer 5
Last day in the month 30
Week of year [B]22[/B]
Week number should be 23
Any idea how to get around this problem?