week number of anydate from datepicker

30 views Asked by At

I want to get the week number from the date picker that user select even if the date was past date;

String dateofweek= dateselect.getText().toString();
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Date date = null;



try {
    date=format.parse(dateofweek);
} catch (ParseException e) {
    e.printStackTrace();
}


Calendar cal2 = Calendar.getInstance();
cal2.setTime(date);

int weekofdate= cal2.get(Calendar.WEEK_OF_YEAR);

I tried this but it is showing same week number for every week.

0

There are 0 answers