I'm doing my first application on Android, it consists of a "To do Task". My problem is when I want to check the text of my TextView
, which contains the date (array of strings), with the date on which the information is saved. This if I do to run the check never works.
// Write date in Array
SimpleDateFormat formatdate = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
Calendar calendar = new GregorianCalendar();
String[] date = new String[6];
for(int i = 0; i < 6;i++){
calendar.add(Calendar.DATE , 1);
date[i] = formatdate.format(calendar.getTime());
}
tvdate2.setText(date[0]); // 16-03-2021
...
// When clicking on the button, it checks and then displays the corresponding information
btn2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String test ="16-03-2021";
if (tvdate2.getText().toString() == test){
testing.setText("It works!!");
}
}
});