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 ..
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
Calendar calender = Calendar.getInstance(); Log.d("Current Week:" + calender.get(Calendar.WEEK_OF_YEAR));
Calendar sDateCalendar = new GregorianCalendar(2013,03,01); Calendar.getInstance().get(Calendar.WEEK_OF_YEAR);
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);
Calendar calender = Calendar.getInstance (); Log.d ("This week:" + calender.get (Calendar.WEEK_OF_YEAR));