How to get all dates between two dates in Android.
For example. I have two Strings.
String first=\"2012-07-15\";
String second=\"2012-07-21\";
public class DummyWorks extends Activity
{
static final long ONE_DAY = 24 * 60 * 60 * 1000L;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getDatesBetween("03/23/2011","03/28/2011");
}
public static void getDatesBetween(String startDate,String endDate) {
long from=Date.parse(startDate);
long to=Date.parse(endDate);
int x=0;
while(from <= to) {
x=x+1;
System.out.println ("Dates : "+new Date(from));
from += ONE_DAY;
}
System.out.println ("No of Dates :"+ x);
}
}