У меня есть метод, который забирает записи (с именем runtime) из базы данных SQL, связанной с Hibernate.Проблема возникает, когда я хочу отфильтровать результаты по дате.Я объявил переменную с датой, с которой я хочу увидеть результаты, но она никогда не проходит через оператор «если».В Отладчике я вижу, что эти две даты для сравнения имеют одинаковый формат, я не знаю, почему это не работает.Любые идеи?
я присоединяю экраны с состоянием переменных отладчика, проблема возникает, когда я проверяю, если -> runtime.getDateTime после переменной 'reportDateFrom'.
состояние переменной отладчика ->https://scontent -waw1-1.xx.fbcdn.net / v / t1.15752-9 / 64350066_418943105623455_284358622048157696_n.png? _nc_cat = 110 & _nc_ht = scontent-waw1-1.xx & о = a2ff24ad936bc2843658afe9dc130128 & ае = 5D881E1E
метод -> https://scontent -waw1-1.xx.fbcdn.net / v / t1.15752-9 / 64673116_2354086638248857_6383211241770319872_n.png? _Nc_cat = 111 & _nc_ht = scontent-waw1e0506506105
public int getUpTimeInMinutes(String machineName) {
machineName = "4x2 brick mould";
List<Runtime> runTime = runtimeRepository.findAllByMachineName(machineName);
LocalDateTime reportDateFrom = LocalDateTime.of(2019, 1, 7, 0, 0, 0);
// Method will calculate the difference between the two records when the machine had the isRunning =1 and 0
String previousRecordTime = null;
String actualRecordTime;
int minutesUptime = 0;
for (Runtime runtime : runTime) {
// first i filter from the date requested
if (runtime.getDatetime().isAfter(reportDateFrom)) {
if (runtime.getIsRunning() == 1) {
// below i save the record where machine started working and convert it first to LocalTime and then to String of format HH:mm
previousRecordTime = runtime.getDatetime().toLocalTime().toString();
} else if (runtime.getIsRunning() == 0) {
// below i save the date where machine stopped working and calculate the difference between the two records using another method
actualRecordTime = runtime.getDatetime().toLocalTime().toString();
minutesUptime += calculateDifferenceBetweenStrings(previousRecordTime, actualRecordTime);
}
}
}
return minutesUptime;
}