/** * Calculate whether given hours can be fitted to the given week. Each day is assumed 8 hours * long. * * @param currentWeek * @param targetWeek * @param totalWorkload * @return */ private boolean isAccommodableWorkload( int currentWeek, int targetWeek, AFTime totalWorkload, User user) { if (user == null) { return false; } long totalInWeek = 5; int daysLeft = 5; if (currentWeek == targetWeek) { Calendar cal = GregorianCalendar.getInstance(); daysLeft = 1; while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.FRIDAY && daysLeft < 6) { cal.add(Calendar.DAY_OF_YEAR, 1); daysLeft++; } } totalInWeek = (long) (user.getWeekHours().getTime() * (1.0 * daysLeft * settingBusiness.getCriticalLow() / (5 * 100))); if (totalInWeek < totalWorkload.getTime()) { return false; } return true; }