I am trying to compare the current date with the date stored in the array, but I am not able to compare the date using if
condition.
I use this code to compare the date:
DateFormat TO = new SimpleDateFormat("yyyy-MM-dd ");
Today = TO.format(Calendar.getInstance().getTime());
for (int i = 0; i < jsonArray.length(); i++) {
// Today has a value 2018-03-13
// ScheduleDates[i] has a value 2018-03-13
// ScheduleDates[10] has a value 2018-03-13
if (Today.equals(ScheduleDates[i])) {
Toast.makeText(Main2Activity.this, "Match Found" + ScheduleDates[i] + "--"
+ StartTimes[i] + "--" + Endtimes[i], Toast.LENGTH_LONG).show();
break;
} else {
Toast.makeText(Main2Activity.this, "Match Not Found", Toast.LENGTH_LONG).show();
break;
}
}
But when I run the loop it shows only "match not found"
. I cannot find what error I had made, can anyone help to find the error?