I am creating an Android Studios tasklist app. For some reason, an IF statement is being called even though the expression is false, and thus producing errors at runtime. Code is provided below:
if (taskArray5.get(0).equals( "Goal Time Not Specified") ) {
Log.d("hello", taskArray5.get(0).getClass().toString());
Log.d("hello", taskArray5.get(0));
String[] localTimeList = localTime.split(":");
String previouslySetTime = taskArray5.get(0).substring(0, taskArray5.get(0).length() - 5);
String[] previouslySetTimeList = previouslySetTime.split(":");
Integer localTimeHours = Integer.parseInt(localTimeList[0]);
Integer localTimeMinutes = Integer.parseInt(localTimeList[1]);
Integer localTimeSeconds = Integer.parseInt(localTimeList[2]);
char AMORPM = taskArray5.get(0).charAt(taskArray5.get(0).length() - 4);
Integer previouslySetTimeHours;
if (AMORPM == 'A') {
previouslySetTimeHours = Integer.parseInt(previouslySetTimeList[0]);
} else {
previouslySetTimeHours = Integer.parseInt(previouslySetTimeList[0]) + 12;
}
I used Log.d to confirm that taskArray5.get(0) is a String that has the specific value "Goal Time Not Specified." In addition, using the equals() function also did not solve the problem. What am I doing wrong? Any help is appreciated.