private void checkForFine(String bookItemBarcode) { BookLending bookLending = BookLending.fetchLendingDetails(bookItemBarcode); Date dueDate = bookLending.getDueDate(); Date today = new Date(); // check if the book has been returned within the due date if (today.compareTo(dueDate) > 0) { long diff = todayDate.getTime() - dueDate.getTime(); long diffDays = diff / (24 * 60 * 60 * 1000); Fine.collectFine(memberId, diffDays); } }