Android (How to find list of dates with a interval of 10 days) -


i developing android application , getting start date , end date server.

eg: 20-06-2016 , 20-06-2017

i want find list of dates between these 2 dates interval of 10 days. excluding saturday , sunday.

for example: 20-06-2016 monday next date should 04-07-2016(excluded saturday , sunday). , on.

after on each date(from list of dates) want add event in calendar on particular date can notify user message.

i wrote code adds event in calendar , notify user on particular time. want list of dates.

please me out.

thank you.

i somehow managed accomplished task.

here code

public list<string> finddates(string startdate,string enddate) throws parseexception {         list<date> dates = new arraylist<date>(); //this list store dates startdate enddate         list<string> intervaldates = new arraylist<>(); //this list store dates excluding saturday , sunday.          dateformat formatter;         formatter = new simpledateformat("mm-dd-yyyy");          date sdate = (date) formatter.parse(startdate);         date edate = (date) formatter.parse(enddate);         long interval = 24 * 1000 * 60 * 60; // 1 day in millis         long endtime = edate.gettime(); // create endtime here, possibly using calendar or date         long curtime = sdate.gettime();         while (curtime <= endtime) {             dates.add(new date(curtime));              curtime += interval;  //adding interval of 1day         }          (int = 0; < dates.size(); i++) {             date ldate = (date) dates.get(i); // getting each date list of dates find day name             string ds = formatter.format(ldate);              date day = formatter.parse(ds);             dateformat dayformat = new simpledateformat("eeee");             string dy = dayformat.format(day); // day name              if (dy.equalsignorecase("saturday") || dy.equalsignorecase("sunday")) {                 continue;             }             intervaldates.add(ds); //adding date excluding saturday , sunday.              //log.d(tag, "finddates: date is:" + ds + " " + dy);         }         return intervaldates;     } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -