0

So i've done this code to get the time passed between the current date and another date but it always returns only the difference in minutes for example i want to subtract 10/5/2019,20:30 from 11/5/2019,20:50 it only returns 20 which is the number of minutes that passed but it dosen't give the whole difference with days and everything

here what my code looks like

Date datee = new Date();
        SimpleDateFormat df1 = new SimpleDateFormat("dd MMM YYYY, HH:mm");
        String currentdate = df1.format(datee);

        String dateStr = msg.getDate();


        try {
            Date messageDate = df1.parse(dateStr);
            Date currentDate = df1.parse(currentdate);


            long dif = (currentDate.getTime() - messageDate.getTime())/60000;


            holder.dateTextView.setText(String.valueOf(dif));




        } catch (ParseException e) {
            e.printStackTrace();
        }

and thanks !

Joee
  • 57
  • 7
  • 1
    your response will always be in minutes, you need to format it yourself into hours days weeks etc. – a_local_nobody Aug 01 '19 at 18:25
  • Possible duplicate of [SimpleDateFormat producing wrong date time when parsing "YYYY-MM-dd HH:mm"](https://stackoverflow.com/questions/15916958/simpledateformat-producing-wrong-date-time-when-parsing-yyyy-mm-dd-hhmm) – Ole V.V. Aug 01 '19 at 19:33

0 Answers0