There is a method and briefly about it:

String fromDateString = DateTools.formatToLongDateFormat(datePeriod.startDate); String toDateString = DateTools.formatToLongDateFormat(datePeriod.endDate); 

Then I write the conditions under which my values ​​are equal.

 if (datePeriod.startDate.isEqual(datePeriod.endDate)) { return fromDateString; } 

And what turns out, instead of two dates, I get one, but the essence is not important, the essence is that the task is that when this condition is met, namely when starDate = endDate, besides return fromDateString; An additional text value TODAY was displayed.

    4 answers 4

    Now you can return several values ​​of different types from the method without creating extra classes using android.util.Pair<F, S> so

     pubic Pair<String, String> getPair() { return new Pair<String, String>("firstString", "secondString"); } 

    You need to receive data like this:

     String first = getPair().first; String second = getPair().second; 

      Well, you can just add the following return'a :

       fromDateString = "TODAY"; 
         if (datePeriod.startDate.isEqual(datePeriod.endDate)) { fromDateString="TODAY - " + fromDateString; return fromDateString; } 
           String fromDateString = DateTools.formatToLongDateFormat(datePeriod.startDate); String toDateString = DateTools.formatToLongDateFormat(datePeriod.endDate); StringBuilder sb = new StringBuilder(); sb.append("TODAY - "); sb.append(fromDateString); if (datePeriod.startDate.isEqual(datePeriod.endDate)) { return sb; }