-1
GregorianCalendar last = new GregorianCalendar(py,pm-1,pd);
System.out.println(last.getTime());
GregorianCalendar present = new GregorianCalendar(py,pm-1,pd);
System.out.println(present.getTime());

long diff = Math.abs(prsent.getTime() - last.getTime());

Problem facing when subtracting these two dates

1 Answers1

0

ChronoUnit is what you can use for the difference between dates:

long minutesDiff = ChronoUnit.MINUTES.between(present.toInstant(), last.toInstant());
KayV
  • 12,987
  • 11
  • 98
  • 148