I want to calculate the difference in minutes between one date and another, however when this difference is greater than 45, I want it to say that it goes "x minutes late", if they pass "and" minute (s) should show: " x + and late minutes " I currently have this, it works perfectly when the current date is less than the date that must be fulfilled:
Date fechaactual = new Date();
long diff = trackingfecha.getTime() - fechaactual.getTime();
long diferenciaminutos = diff / (60 * 1000);
RunneableUpdateUI run = new RunneableUpdateUI();
if(diffMinutes < 45.0) {
if(diffMinutes >= 0) {
//Se muestran los minutos restantes para llegar a la fecha trackingfecha
StringBuffer buffer = new StringBuffer();
buffer.append("te quedan ");
String minutes = String.format("%02d", diffMinutes);
buffer.append(minutes);
buffer.append(" min");
run.toUpdateValue = buffer.toString();
} else {
//Actualmente aqui es el problema, siempre que hago la operación muestra números completamente incongruentes, como 200 minutos tarde. Incluso cuando la diferencia es de solamente 60 minutos.
StringBuffer buffer = new StringBuffer();
String minutes = String.format("%02d", Math.abs(diffMinutes));
buffer.append(minutes);
buffer.append(" min tarde");
run.toUpdateValue = buffer.toString();
}
timerHandler.post(run);
}
I want to calculate the time it takes to reach a specific date and if it goes beyond this specific date, show how late it is going.