public long getTotalPages(String d, int pSize) { DateFormat dateformat = new SimpleDateFormat("yyyy-mm-dd"); Date dayEnd = new Date(); try { dayEnd = new Date((dateformat.parse(d).getTime() + 24 * 60 * 60 * 1000)); System.out.println(auiRepo.totalLogsBetween(d, dateformat.format(dayEnd))); } catch (ParseException e) { e.printStackTrace(); } return Math.round( Math.ceil(auiRepo.totalLogsBetween(d, dateformat.format(dayEnd)) / (double) pSize)); }