java - How to print all day of week in android -
i want display day of week on click of button. action this, illustration suppose month feb - 2013, on click of button first time want display days.
3/11/2013, 4/11/2013, 5/11/2013, 6/11/2013, 7/11/2013, 8/11/2013, 9/11/2013
on click of button sec time want display this
10/11/2013, 11/11/2013, 12/11/2013, 13/11/2013, 14/11/2013, 15/11/2013, 16/11/2013
similarly on each click of button want display rest of days in format. how can done, have tried code display
3/11/2013, 4/11/2013, 5/11/2013, 6/11/2013, 7/11/2013, 8/11/2013, 9/11/2013
code used
calendar c = calendar.getinstance(); // set calendar mon of current week c.set(calendar.day_of_week, calendar.sunday); // print dates of current week starting on mon dateformat df = new simpledateformat("dd/mm/yyyy", locale.us); (int = 0; < 7; i++) { system.out.println(df.format(c.gettime())); c.add(calendar.day_of_month, 1); }
yours there, added c.add(calendar.week_of_year, week);
increment week based on input parameter
public static void getdaysofweek(int week) { calendar c = calendar.getinstance(); // set calendar mon of current week c.set(calendar.day_of_week, calendar.sunday); c.add(calendar.date, week * 7); // print dates of current week starting on mon dateformat df = new simpledateformat("dd/mm/yyyy", locale.us); (int = 0; < 7; i++) { system.out.println(df.format(c.gettime())); c.add(calendar.day_of_month, 1); } }
use above method days of week. pass 0 first time method, 1 next click , on. corresponding days of week.
java android date
No comments:
Post a Comment