Get dates for a given week number in Android -
i dates given week number. instance, if have week number 15, need dates: 05-04-2015, 06-04-2015, 07-04-2015, 08-04-2015, 09-04-2015, 10-04-2015, 11-04-2015.
is possible? if so, how?
let me know,
thanks!
here solution:
calendar c = new gregoriancalendar(locale.getdefault()); c.set(calendar.week_of_year, 15); c.set(calendar.year, 2015); string result = ""; int firstdayofweek = c.getfirstdayofweek(); (int = firstdayofweek; < firstdayofweek + 7; i++) { c.set(calendar.day_of_week, i); result += new simpledateformat("yyyy.mm.dd").format(c.gettime()) + "\n"; }
as input, except week, need have year. pay attention first day of week depends on locale.