System that controls Work Orders, the moment I open a new work order call I close the previous order. If the previous work order has been opened on an earlier date (at least one day late) I close it at the end of the previous date and open the new one at the beginning of the current day's work.
What I'm wanting with this, a way of knowing if the date in question is at least a day earlier. I thought about testing the difference in hours between the end of the day's workday and the start of the current day's work, but that does not seem to be a good solution.
I ran a test with calendar as follows:
Calendar diaAnterior = DATA_HORA_INICIAL_OS;
diaAnterior.add(Calendar.DATE, 1);
if (DATA_HORA_ATUAL.get(Calendar.DATE) >= diaAnterior.get(Calendar.DATE)) {
return true;
}
return false;
But in this way it only tests the day in question and if it was opened on the 30th of the month and today is day 1, the method will return an invalid information, or if you went on vacation and returned at the beginning of the month, the same error would occur.
So, how can I test if the opening date of the service order is at least the previous day?