2
System that controls Orders of Service, the moment I open a new service order I close the previous order. If the previous service order was opened on an earlier date (at least one day ago) I close it at the end of the previous day’s working hours and open the new one at the beginning of the current day’s working hours.
What I’m wanting with this, a way to find out if the date in question is at least a day earlier. I thought about testing the time difference between the end of the previous day’s working hours and the beginning of the current day’s working hours, but it doesn’t seem like a good solution.
I did a test with Legend 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;
However this way it just tests the day in question and if it has been opened the day 30 of the month and today is day 1, the method will return me invalid information, or if I have gone on vacation and come back at the beginning of the month, the same error would happen.
So how can I test whether the date of the opening of the work order is at least the previous day?
Taking the opportunity, I leave you a recommendation to use the new date API, which is more efficient.
– user28595
Poh! Thanks man, I really had no knowledge of this API, I’ll take a look. Problem for me that Java 8 no longer accepts Windows XP.
– Paulo H. Hartmann