Calendar instance providing wrong week number when calendar built with basic fields

djbarca

New Member
I would like to understand why this happens, and how can i solve this small issue.I would like to be able to get the week number from a java calendar instance after providing the day, the month and the year.if i do:\[code\] Calendar cal=Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 11); cal.set(Calendar.MONTH,2); cal.set(Calendar.YEAR, 2013);\[/code\]11 Feb 2013 is week 7, but if i invoke, in the above calendar instance:\[code\]int weekNumber=cal.get(Calendar.week_of_year)\[/code\]I get the week number 11.Any idea why?I tried setting the locale but no difference, the problem is that i can only build a calendar out of these three fields, since i'm reading them from a xml file with a parser and they are in format dd-mm-yyyy with no more information that that
 
Back
Top