private boolean isMessageInSameDate(Message message1,Message message2){
  boolean isSameDate=false;
  if (message1.yearOfCreated != -1 && message2.yearOfCreated != -1) {
    isSameDate=message1.yearOfCreated == message2.yearOfCreated && message1.dayOfYearCreated == message2.dayOfYearCreated;
  }
 else {
    Calendar cal1=Calendar.getInstance();
    Calendar cal2=Calendar.getInstance();
    cal1.setTimeInMillis(message1.created);
    cal2.setTimeInMillis(message2.created);
    isSameDate=cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
    message1.dayOfYearCreated=cal1.get(Calendar.DAY_OF_YEAR);
    message1.yearOfCreated=cal1.get(Calendar.YEAR);
    message2.dayOfYearCreated=cal2.get(Calendar.DAY_OF_YEAR);
    message2.yearOfCreated=cal2.get(Calendar.YEAR);
  }
  return isSameDate;
}

private boolean isMessageInSameDate ( Message message1 , Message message2 ) { boolean isSameDate = false ; if ( message1 . yearOfCreated != - 1 && message2 . yearOfCreated != - 1 ) { isSameDate = message1 . yearOfCreated == message2 . yearOfCreated && message1 . dayOfYearCreated == message2 . dayOfYearCreated ; } else { Calendar cal1 = Calendar . getInstance ( ) ; Calendar cal2 = Calendar . getInstance ( ) ; cal1 . setTimeInMillis ( message1 . created ) ; cal2 . setTimeInMillis ( message2 . created ) ; isSameDate = cal1 . get ( Calendar . YEAR ) == cal2 . get ( Calendar . YEAR ) && cal1 . get ( Calendar . DAY_OF_YEAR ) == cal2 . get ( Calendar . DAY_OF_YEAR ) ; message1 . dayOfYearCreated = cal1 . get ( Calendar . DAY_OF_YEAR ) ; message1 . yearOfCreated = cal1 . get ( Calendar . YEAR ) ; message2 . dayOfYearCreated = cal2 . get ( Calendar . DAY_OF_YEAR ) ; message2 . yearOfCreated = cal2 . get ( Calendar . YEAR ) ; } return isSameDate ; }
check is messages in same day
