when i ran the following file , I am getting the incorrect results.
public class Week
public static void main( String args ) throws Exception
//String sdate = "30-DEC-2006";
String sdate = "31-DEC-2006";
String sdate1 = "01-JAN-2007";
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MMM-yyyy");
java.util.Date dt = sdf.parse(sdate);
java.util.Date dt1 = sdf.parse(sdate1);
Calendar calendar = Calendar.getInstance();
System.out.println("Week of year for 31-DEC-2006 is : =>"+calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println("Week of year for 01-JAN-2007 is : =>"+calendar.get(Calendar.WEEK_OF_YEAR));
Week of year for 31-DEC-2006 is : =>53
Week of year for 01-JAN-2007 is : =>53
Can anyone tell me how to fix this issues.
Did you listen about documentation? It takes about one minute to find followed: For example, a specific Calendar subclass may designate the week before week 1 of a year as week n of the previous year.
You should spend few minutes more to find how to fix it.