Why does not it work? It is necessary that the text be displayed on a certain date. help me please

TextView tv = (TextView) findViewById(R.id.textView2); SimpleDateFormat dfDate_day= new SimpleDateFormat("dd.MM"); String dt=""; Calendar c = Calendar.getInstance(); String data = dfDate_day.format(c.getTime()); String data2 = "09.02"; if(data==data2){ data = "Happy!"; } tv.setText(data); 

    1 answer 1

    Strings cannot be compared with the operator ==

    Strings are compared using the equels () method .

    For your case:

     if (data.equels(data2)) 
    • Thanks for the reply) Only equals ();) - PSam