How to calculate week number for a given Android date

I am trying to get the current week number from the specified date. those. if I enter the date as 01/03/2013, then I have to get the week number, which is 9 ..

Please help me find a solution.

Thanks..

Abhishek ..

+6
source share
5 answers

You can create a Calendar object for this date and get a week using calendar.get (Calendar. WEEK_OF_YEAR). The API is described here: http://developer.android.com/reference/java/util/Calendar.html#WEEK_OF_YEAR

+13
source
Calendar calender = Calendar.getInstance(); Log.d("Current Week:" + calender.get(Calendar.WEEK_OF_YEAR)); 
+7
source
 Calendar sDateCalendar = new GregorianCalendar(2013,03,01); Calendar.getInstance().get(Calendar.WEEK_OF_YEAR); 
+3
source

03/01/2013 taken in the form of 113, 2, 1

  Date d = new Date(113, 2, 1); Calendar c = Calendar.getInstance(); c.setTime(d); int weekOfYear = c.get(Calendar.WEEK_OF_YEAR); 
0
source

Calendar calender = Calendar.getInstance (); Log.d ("This week:" + calender.get (Calendar.WEEK_OF_YEAR));

0
source

All Articles