I have a string with name of days in it , i just want to see that in that string of days , which is the upcoming day. For example the string contains "Sun,Mon,Tue,Fri,Sat" and if today is Wednesday it should return fri only. Anyone got an idea how to do this? At the moment i am doing this thing but it seems to return sun too although sunday is already past.
static String[] strDays = new String[] { "Sun", "Mon", "Tue", "Wed", "Thu",
"Fri", "Sat" };
String nexday="sun,mon,tue,fri,sat";
String nexdayone[] = nexday.split(",");
Calendar now = Calendar.getInstance();
Calendar futurecal = Calendar.getInstance();
for (int i = 0; i < nexdayone.length; i++) {
for (int j = 0; j < 7; j++) {
if (strDays[j].equalsIgnoreCase(nexdayone[i])) {
futurecal.set(Calendar.DAY_OF_WEEK, j);
if (futurecal.after(now)) {
Log.d(now.get(Calendar.DAY_OF_WEEK)+" --after-- "+j,""+strDays[j]);
break;
}
}
}
}