android - How to increment the date selected from the date picker? -


below code. trying achieve here selecting date date picker , setting currettoday. when go next date it's incrementing today's date rather incrementing selected date. don't know going wrong. please me out.

    getdate(icount);      iv_refresh.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              icount = 0;             getdate(icount);         }     });      rightarrow.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {                   getdate(++icount);          }     });      leftarraow.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             getdate(--icount);         }     });        apptitletextview = (textview) findviewbyid(r.id.tool_bar_app_title_textview);      toggle = new actionbardrawertoggle(             this, drawer, toolbar, r.string.drawer_open, r.string.drawer_close); } private void getdate(int i) {      if(new datepickerfragment(tv_date).datepickerdate == null) {         calendar calendar = calendar.getinstance();         calendar.add(calendar.day_of_year, i);         currenttoday = dateformat.format(calendar.gettime());         tv_date.settext(currenttoday);       } else {          calendar calendar = calendar.getinstance();         calendar.add(calendar.day_of_year,i);         currenttoday =new datepickerfragment(tv_date).datepickerdate;         tv_date.settext(currenttoday);       } 

this out date incremented

public date getincrementeddate(date selecteddate) {     simpledateformat sdf = new simpledateformat("yyyy-mm-dd");     calendar c = calendar.getinstance();     c.settime(sdf.parse(selecteddate));     c.add(calendar.date, 1);  // number of days add     selecteddate = sdf.format(c.gettime());  // selecteddate new date return selecteddate; } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -