Buenas,
Para calcular la diferencia entre fechas, lo puedes hacer facilmente con TimeUnit. Un ejemplo:
Código Java:
Ver originalpublic static void main
(String[] args
) {
long diff = date1.getTime() - date2.getTime();
long days = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS);
diff = diff - TimeUnit.MILLISECONDS.convert(days, TimeUnit.DAYS);
long hours = TimeUnit.HOURS.convert(diff, TimeUnit.MILLISECONDS);
diff = diff - TimeUnit.MILLISECONDS.convert(hours, TimeUnit.HOURS);
long minutes = TimeUnit.MINUTES.convert(diff, TimeUnit.MILLISECONDS);
diff = diff - TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES);
long seconds = TimeUnit.SECONDS.convert(diff, TimeUnit.MILLISECONDS);
System.
out.
println(TimeUnit.
DAYS + ":" + days
); System.
out.
println(TimeUnit.
HOURS + ":" + hours
); System.
out.
println(TimeUnit.
MINUTES + ":" + minutes
); System.
out.
println(TimeUnit.
SECONDS + ":" + seconds
); }
Un saludo