public static String dateToText(Context context,Date date){
  String textDate;
  date=truncateHours(date);
  Calendar c=Calendar.getInstance();
  c.set(Calendar.HOUR_OF_DAY,0);
  c.set(Calendar.MINUTE,0);
  c.set(Calendar.SECOND,0);
  c.set(Calendar.MILLISECOND,0);
  Date today=c.getTime();
  c.add(Calendar.DATE,-1);
  Date yesterday=c.getTime();
  if (date.equals(today)) {
    textDate=context.getString(R.string.today_s);
  }
 else   if (date.equals(yesterday)) {
    textDate=context.getString(R.string.yesterday_s);
  }
 else {
    textDate=formatDate(date,new SimpleDateFormat("dd.MM"));
  }
  return textDate;
}

public static String dateToText ( Context context , Date date ) { String textDate ; date = truncateHours ( date ) ; Calendar c = Calendar . getInstance ( ) ; c . set ( Calendar . HOUR_OF_DAY , 0 ) ; c . set ( Calendar . MINUTE , 0 ) ; c . set ( Calendar . SECOND , 0 ) ; c . set ( Calendar . MILLISECOND , 0 ) ; Date today = c . getTime ( ) ; c . add ( Calendar . DATE , - 1 ) ; Date yesterday = c . getTime ( ) ; if ( date . equals ( today ) ) { textDate = context . getString ( R . string . today_s ) ; } else if ( date . equals ( yesterday ) ) { textDate = context . getString ( R . string . yesterday_s ) ; } else { textDate = formatDate ( date , new SimpleDateFormat ( "dd.MM" ) ) ; } return textDate ; }
converts a date to the textual representation of dates used by people .
