title: Detecting the previous item in recycler view
body: <p>I have a model class called (messages). In on bind view holder method of recycler view adapter I do this to extract the (time) string from the (messages) class:</p>
  
  <pre><code>@override
  public void onBindViewHolder(final ViewHodler view holder, int position){
  
    //here I extract the time value from (messages) class
  
    messages mess=messageslist.get(position);
  
    //I store it in a long variable called time
  
    long time= mess.getTime();
  
  
   }
  </code></pre>
  
  <p>Until here I am only getting the time value of each item in recycler view. But I want also to get the time of the previous item and compare it to the next one.</p>
  
  <p><strong>In other words I am trying to find the difference of time between each 2 items in recyclerview.</strong></p>
  
  <p>Thanks for your help.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>okay what I want to do is to show or hide a date view if the difference of date between the 2 items reached or passed 1 day. If I do it according to the answers below I get no results...like this</p>
  
  <pre><code>    //the time of the item
      long time= mess.getTime();
  
       //the time of the previous item according to the answers below
  
      long pre_time=messageslist.get(position-1).getTime();
  
  
       //now I compare the difference 
  
  
        if(time - pre_time &gt;= 24*3600*1000){ 
  
           //show date
         }else{
           //hide date
          }
  </code></pre>
  
  <p>but doest work.    </p>