String calculateDisplayTimestamp(long time){
        long now = System.currentTimeMillis()/1000;
        long diff = now-time;
        if(diff < 60){
            return "Just Now";
        }else if(diff > 60 && diff < 59*60){
            return (diff/(60)) + " mins ago";
        }else if(diff > 59*60 && diff < 23*59*60 ){
            return diff/(60*60) > 1 ? diff/(60*60) + " hours ago" : diff/(60*60) + " hour ago";
        }else if(diff > 24*60*60 && diff < 48*60*60){
            return "Yesterday";
        }else {
            @SuppressLint("SimpleDateFormat")
            SimpleDateFormat sdf = new SimpleDateFormat("dd MMM");
            return sdf.format(new Date(time));
        }
    }
String calculateDisplayTimestamp ( long time ) { long now = System . currentTimeMillis ( ) / 1000 ; long diff = now - time ; if ( diff < 60 ) { return "Just Now" ; } else if ( diff > 60 && diff < 59 * 60 ) { return ( diff / ( 60 ) ) + " mins ago" ; } else if ( diff > 59 * 60 && diff < 23 * 59 * 60 ) { return diff / ( 60 * 60 ) > 1 ? diff / ( 60 * 60 ) + " hours ago" : diff / ( 60 * 60 ) + " hour ago" ; } else if ( diff > 24 * 60 * 60 && diff < 48 * 60 * 60 ) { return "Yesterday" ; } else { @ SuppressLint ( "SimpleDateFormat" ) SimpleDateFormat sdf = new SimpleDateFormat ( "dd MMM" ) ; return sdf . format ( new Date ( time ) ) ; } }
Logic for timestamp
@param time Epoch date of creation
@return String timestamp