Example usage for java.util Date before

List of usage examples for java.util Date before

Introduction

In this page you can find the example usage for java.util Date before.

Prototype

public boolean before(Date when) 

Source Link

Document

Tests if this date is before the specified date.

Usage

From source file:be.agiv.security.AGIVSecurity.java

/**
 * Refreshes all cached security tokens. Can be used by a background process
 * in order to minimize the possible delay on clients because of expired
 * security tokens. The returned expiry date can be used to program a timer
 * at which the method should be called again. Don't forget to take the
 * token retirement duration into account when programming such a timer.
 * //from ww  w.j a v  a  2s .c om
 * @return the expiry date of the token that expires next in line.
 */
public Date refreshSecurityTokens() {
    refreshIPSTSSecurityToken();
    Date expiryDate = this.ipStsSecurityToken.getExpires();
    Set<String> serviceRealms = this.rStsSecurityTokens.keySet();
    if (serviceRealms.isEmpty()) {
        return expiryDate;
    }
    for (String serviceRealm : serviceRealms) {
        SecurityToken rStsSecurityToken = refreshRSTSSecurityToken(serviceRealm);
        Date rStsExpiryDate = rStsSecurityToken.getExpires();
        if (rStsExpiryDate.before(expiryDate)) {
            expiryDate = rStsExpiryDate;
        }
    }
    Set<String> serviceLocations = this.secureConversationTokens.keySet();
    if (serviceLocations.isEmpty()) {
        return expiryDate;
    }
    for (String serviceLocation : serviceLocations) {
        SecurityToken secureConversationToken = this.secureConversationTokens.get(serviceLocation);
        SecurityToken rStsSecurityToken = secureConversationToken.getParentSecurityToken();
        String serviceRealm = rStsSecurityToken.getRealm();
        secureConversationToken = refreshSecureConversationToken(serviceLocation, serviceRealm);
        Date sctExpiryDate = secureConversationToken.getExpires();
        if (sctExpiryDate.before(expiryDate)) {
            expiryDate = sctExpiryDate;
        }
    }
    return expiryDate;
}

From source file:org.jasig.portlet.announcements.mvc.servlet.ApproveAjaxController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    Long annId = Long.valueOf(request.getParameter("annId"));
    Boolean approval = Boolean.valueOf(request.getParameter("approval"));
    Announcement ann = announcementService.getAnnouncement(annId);

    Date startDisplay = ann.getStartDisplay();
    Date endDisplay = ann.getEndDisplay();
    if (endDisplay == null) {
        // Unspecified end date means the announcement does not expire;  we 
        // will substitute a date in the future each time this item is 
        // evaluated.
        long aYearFromNow = System.currentTimeMillis() + Announcement.MILLISECONDS_IN_A_YEAR;
        endDisplay = new Date(aYearFromNow);
    }//from   w ww . ja  v  a  2 s. co m

    Date now = new Date();
    int status = 3;
    /**
     * Scheduled = 0
     * Expired   = 1
     * Showing   = 2
     * Pending   = 3
     */
    if (startDisplay.after(now) && endDisplay.after(now) && approval) {
        status = 0;
    } else if (startDisplay.before(now) && endDisplay.after(now) && approval) {
        status = 2;
    } else if (endDisplay.before(now)) {
        status = 1;
    }

    ann.setPublished(approval);
    cacheManager.getCacheManager().getCache("guestAnnouncementCache").flush();

    announcementService.addOrSaveAnnouncement(ann);

    return new ModelAndView("ajaxApprove", "status", status);

}

From source file:org.jasig.portlet.announcements.controller.ApproveAjaxController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    Long annId = Long.valueOf(request.getParameter("annId"));
    Boolean approval = Boolean.valueOf(request.getParameter("approval"));
    Announcement ann = announcementService.getAnnouncement(annId);

    Date startDisplay = ann.getStartDisplay();
    Date endDisplay = ann.getEndDisplay();
    if (endDisplay == null) {
        // Unspecified end date means the announcement does not expire;  we 
        // will substitute a date in the future each time this item is 
        // evaluated.
        long aYearFromNow = System.currentTimeMillis() + Announcement.MILLISECONDS_IN_A_YEAR;
        endDisplay = new Date(aYearFromNow);
    }// w w w  . j a v  a 2 s. co  m

    Date now = new Date();
    int status = 3;
    /**
     * Scheduled = 0
     * Expired   = 1
     * Showing   = 2
     * Pending   = 3
     */
    if (startDisplay.after(now) && endDisplay.after(now) && approval) {
        status = 0;
    } else if (startDisplay.before(now) && endDisplay.after(now) && approval) {
        status = 2;
    } else if (endDisplay.before(now)) {
        status = 1;
    }

    ann.setPublished(approval);
    cm.getCacheManager().getCache("guestAnnouncementCache").flush();

    announcementService.addOrSaveAnnouncement(ann);

    return new ModelAndView("ajaxApprove", "status", status);

}

From source file:edu.cmu.cs.lti.discoursedb.io.mturk.converter.MturkConverterService.java

/**
 * Maps a discussion forum message to DiscourseDB
 * /*w  w w . ja v a 2 s  . c o  m*/
 * @param when
 * @param author
 * @param group
 * @param team
 * @param text
 * @param discourse_name
 * @param dataset_name
 * @param source_file_name
 * @param source_column_name
 * @param source_unique_index
 * 
 * @returns the contribution Id written to the database
 */
public Long mapChat(String when, String author, String group, String team, String text, String discourse_name,
        String dataset_name, String source_file_name, String source_column_name, String source_unique_index) {

    if (when == null) {
        when = sdf.format(dummyTime);
        dummyTime = DateUtils.addMinutes(dummyTime, 1);
    }

    Discourse curDiscourse = discourseService.createOrGetDiscourse(discourse_name);

    User curUser = userService.createOrGetUser(curDiscourse, author);
    ContributionTypes mappedType = null;

    log.trace("Create Content entity");
    Content curContent = contentService.createContent();
    curContent.setText(text);
    curContent.setAuthor(curUser);
    dataSourceService.addSource(curContent, new DataSourceInstance(source_unique_index,
            source_file_name + "#" + source_column_name + "(content)", DataSourceTypes.BAZAAR, dataset_name));

    log.trace("Create Contribution entity");
    Contribution curContribution = contributionService.createTypedContribution(ContributionTypes.POST);
    curContribution.setCurrentRevision(curContent);
    curContribution.setFirstRevision(curContent);
    dataSourceService.addSource(curContribution,
            new DataSourceInstance(source_unique_index,
                    source_file_name + "#" + source_column_name + "(contribution)", DataSourceTypes.BAZAAR,
                    dataset_name));
    discussion_source2ddb.put(Long.valueOf(source_unique_index), curContribution.getId());

    DiscoursePart team_chat = discoursepartService.createOrGetDiscoursePartByDataSource(curDiscourse,
            group + "_" + team, "xustudty#teamchat", DataSourceTypes.BAZAAR, dataset_name,
            DiscoursePartTypes.CHATROOM);
    team_chat.setName("Team " + group + "_" + team + " chat");
    DiscoursePart team_dp = discoursepartService.createOrGetTypedDiscoursePart(curDiscourse,
            teamDpName(group, team), DiscoursePartTypes.TEAM);
    discoursepartService.createDiscoursePartRelation(team_dp, team_chat, DiscoursePartRelationTypes.SUBPART);
    discoursepartService.addContributionToDiscoursePart(curContribution, team_chat);

    //parse and set creation time for content and contribution
    try {
        Date date = forgiving_date_parse(when);
        curContent.setStartTime(date);
        curContent.setEndTime(date);
        curContribution.setStartTime(date);
        curContribution.setEndTime(date);
        if (team_chat.getEndTime() == null || date.after(team_chat.getEndTime())) {
            team_chat.setEndTime(date);
        }
        if (team_chat.getStartTime() == null || date.before(team_chat.getStartTime())) {
            team_chat.setStartTime(date);
        }
    } catch (ParseException e) {
        log.error("Could not parse creation time " + when, e);
    }

    return curContribution.getId();

}

From source file:com.linuxbox.enkive.filter.EnkiveFilter.java

private boolean filterDate(String value) throws java.text.ParseException {
    boolean matched = false;

    Date dateValue = dateFormatter.parse(value);
    Date dateFilterValue = dateFormatter.parse(filterValue);

    switch (filterComparator) {
    case FilterComparator.MATCHES:
        if (dateValue.equals(dateFilterValue))
            matched = true;/*from   w w  w .j a  v a 2 s  . c o  m*/
        break;
    case FilterComparator.DOES_NOT_MATCH:
        if (!dateValue.equals(dateFilterValue))
            matched = true;
        break;
    case FilterComparator.IS_GREATER_THAN:
        if (dateValue.after(dateFilterValue))
            matched = true;
        break;
    case FilterComparator.IS_LESS_THAN:
        if (dateValue.before(dateFilterValue))
            matched = true;
        break;
    }
    return matched;
}

From source file:gov.utah.dts.sdc.actions.BaseThirdPartyStudentAction.java

public String insertTrainingTime() throws Exception {
    log.debug("insertTrainingTime");
    //log.debug("observationDate truncated "+ truncateDate(getObservationDate()));
    int start = decodeTime(trainingStartTime);
    Date startDate = new Date(getTrainingDate().getTime() + start);
    log.debug("startDate " + startDate.toString());

    int end = decodeTime(trainingEndTime);
    Date endDate = new Date(getTrainingDate().getTime() + end);
    log.debug("endDate " + endDate.toString());

    if (endDate.before(startDate)) {
        addActionError("Start Time Must Be Before End Time");
    } else {//from   w ww  .  j av a 2 s  .  c o m
        Map<String, Object> hm = new HashMap<String, Object>();
        hm.put("trainingStartTime", startDate);
        hm.put("trainingEndTime", endDate);
        hm.put("section", section);
        hm.put("vehicleFk", vehicleFk);
        hm.put("instructorFk", instructorFk);
        hm.put("classroomFk", classroomPk);
        hm.put("branchFk", branchFk);
        for (int x = 0; x < studentArray.size(); x++) {
            hm.put("studentFk", studentArray.get(x));
            getStudentService().insertTraining(hm);
        }
    }

    if (hasErrors()) {
        return INPUT;
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append("<br/>Training Times Added For ");
        sb.append(studentArray.size());
        if (studentArray.size() == 1) {
            sb.append(" Student");
        } else {
            sb.append(" Students");
        }
        Collection<Object> col = new ArrayList<Object>();
        col.add(sb);
        setThirdPartyAjaxMessages(col);
        return SUCCESS;
    }
}

From source file:com.nec.harvest.controller.UriageController.java

/**
 * This function will be mapped with URL {@link /uriage/ organizationCode}
 * /{businessDay}}, it can be used to render the Sales report with a month
 * for a shop. Will be displayed a message when have a exception or an error
 * occurred/*from w ww. j  av a  2s  .  co  m*/
 * 
 * @param orgCodeStored
 * @param businessDay
 * @param orgCode
 * @param monthly
 * @param request
 * @param model
 * @return String redirect Uri
 */
@RequestMapping("/{orgCode:[a-z0-9]+}/{monthly:[\\d]+}")
public String render(@SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @UserPrincipal User user,
        @PathVariable String proGNo, @PathVariable String orgCode,
        @PathVariable @DateTimeFormat(pattern = "yyyyMM") Date monthly, final Model model) {
    if (logger.isDebugEnabled()) {
        logger.debug("Redering uriage page...");
    }

    logger.info("Trying to generate the uriage template for monthly {} and organization code {}", monthly,
            orgCode);

    String monthlyStr = null;
    try {
        monthlyStr = DateFormatUtil.format(monthly, DateFormat.DATE_WITHOUT_DAY);
        model.addAttribute(PROCESSING_MONTH, monthly);
    } catch (NullPointerException | IllegalArgumentException ex) {
        logger.warn(ex.getMessage());
    }

    // ????
    Organization organization = user.getOrganization();
    if (organization != null) {
        // ????1???""?2???""??
        logger.info(
                "????1???\"\"?2???\"\"??");
        //
        organization = organizationService.findByOrgCode(organization.getStrCode());

        // 
        model.addAttribute(TAX_TYPE, organization.getTaxKbn());
        model.addAttribute(COUNT_DATE, getActualMaximumDayOfMonth(monthly));
        model.addAttribute(ORGANIZATION, organization);
    }

    // Get a list of UriageData(Hendo)/at001 data from DB
    List<SalesChange> salesChanges = null;

    try {
        salesChanges = salesChangeService.findByOrgCodeAndMonth(orgCode, monthlyStr, false);
    } catch (IllegalArgumentException | ObjectNotFoundException ex) {
        logger.warn(ex.getMessage());

    } catch (TooManyObjectsException | ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        model.addAttribute(ERROR, true);
        return getViewName();
    }

    try {
        String nextMontly = BusinessDayHelper.getNextMonthly(monthly, DateFormat.DATE_WITHOUT_DAY);
        boolean checkEmptyMonthly = hasSaleChangesOfMonthly(orgCode, nextMontly);

        // Disable the "NEXT MONTHLY" button if the data of next month is empty or null
        if (!checkEmptyMonthly) {
            nextMontly = null;
        }

        model.addAttribute(NEXT_MONTH, nextMontly);

        String previousMonthly = BusinessDayHelper.getPreviousMonthly(monthly, DateFormat.DATE_WITHOUT_DAY);
        checkEmptyMonthly = hasSaleChangesOfMonthly(orgCode, previousMonthly);

        // Disable the "PREVIOUS MONTHLY" button if the data of previous month is empty or null
        if (!checkEmptyMonthly) {
            previousMonthly = null;
        }
        model.addAttribute(PREVIOUS_MONTH, previousMonthly);
    } catch (ServiceException ex) {
        logger.error(ex.getMessage());

        // ???????????
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        model.addAttribute(ERROR, true);
        return getViewName();
    }

    List<SalesChangeBean> salesChangeBeans = new ArrayList<>();
    if (CollectionUtils.isEmpty(salesChanges)) {
        if (logger.isDebugEnabled()) {
            logger.debug(
                    "sales data of organization code: " + orgCode + " on month: " + monthly + " is not exist.");
        }

        // 
        model.addAttribute(ERROR, true);
        model.addAttribute(ERROR_MESSAGE, MessageHelper.get(MsgConstants.CM_QRY_M01));
        model.addAttribute(EDITABLE, Boolean.FALSE);
        model.addAttribute(SALES_CHANGE_CATEGORY, salesChangeBeans);
        return getViewName();
    }

    try {
        Map<String, Double> rateDefMap = consumptionTaxRateService.findRateDefByMonth(monthly);
        Object[] keySet = rateDefMap.keySet().toArray();
        Double taxRateTmp = 0D;
        String enfDateStrTmp = null;

        String keyStr = null;
        for (SalesChange obj : salesChanges) {
            for (int i = 0; i < keySet.length; i++) {
                keyStr = keySet[i].toString();
                Date actualDate = obj.getSrDate();
                try {
                    Date date = DateFormatUtil.parse(keyStr, FORMAT_DATE);
                    if (!actualDate.before(date)) {
                        //get taxRate with folowed date
                        if (enfDateStrTmp == null
                                || !date.before(DateFormatUtil.parse(enfDateStrTmp, FORMAT_DATE))) {
                            enfDateStrTmp = keyStr;
                            taxRateTmp = rateDefMap.get(keyStr);
                        }
                        keySet = ArrayUtils.removeElement(keySet, keySet[i]);
                        i--;
                    }
                } catch (NullPointerException | ParseException e) {
                    logger.warn("warning parse string to date is error: " + e.getMessage());
                    continue;
                }
            }
            SalesChangeBean bean = new SalesChangeBean(taxRateTmp, obj);
            salesChangeBeans.add(bean);
        }
    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());

        model.addAttribute(ERROR, true);
        model.addAttribute(ERROR_MESSAGE, MessageHelper.get(MsgConstants.CM_QRY_M01));
        return getViewName();
    } catch (ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        model.addAttribute(ERROR, true);
        return getViewName();
    }

    model.addAttribute(SALES_CHANGE_CATEGORY, salesChangeBeans);

    try {
        SalesFixed salesFixedObj = salesFixedService.findByOrgCodeAndMonth(orgCode, monthlyStr, false);
        model.addAttribute(SALES_FIXED, salesFixedObj);
    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());

        // 
        model.addAttribute(SALES_FIXED, null);
    } catch (ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        model.addAttribute(ERROR, true);
        return getViewName();
    }

    // The following source code will be detected the end-user can be changed
    // the sales data or not. If the data already pushed into Tighten table 
    // so that means end-user can not modify the data. Otherwise that is TRUE
    Tighten tighten = null;

    try {
        tighten = tightenService.findByClassifyAndMonth("1");

        // The final month year of tighten
        String sudoOfTighten = tighten.getGetSudo();
        try {
            Date monthlyOfTighten = DateFormatUtil.parse(sudoOfTighten, DateFormat.DATE_WITHOUT_DAY);
            model.addAttribute(EDITABLE, monthly.after(monthlyOfTighten));
        } catch (NullPointerException | ParseException ex) {
            logger.warn(ex.getMessage(), ex);

            // The default is can be edited
            model.addAttribute(EDITABLE, Boolean.TRUE);
        }
    } catch (IllegalArgumentException | ObjectNotFoundException ex) {
        logger.warn(ex.getMessage());

        // If the sales data is not push into the Tighten that means can edit 
        // current data. So the EDITABLE should being Boolean.TRUE
        Date monthsToSubtract = DateUtil.monthsToSubtract(businessDay, 3);
        model.addAttribute(EDITABLE, monthly.after(monthsToSubtract));
    } catch (TooManyObjectsException ex) {
        logger.warn(ex.getMessage(), ex);

        // The default is can be edited
        model.addAttribute(EDITABLE, Boolean.TRUE);
    } catch (ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR, Boolean.TRUE);
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        return getViewName();
    }

    return getViewName();
}

From source file:gov.utah.dts.sdc.actions.BaseThirdPartyStudentAction.java

public String insertObservationTime() throws Exception {
    log.debug("insertObservationTime");
    //log.debug("observationDate truncated "+ truncateDate(getObservationDate()));
    int start = decodeTime(observationStartTime);
    Date startDate = new Date(getObservationDate().getTime() + start);
    log.debug("startDate " + startDate.toString());

    int end = decodeTime(observationEndTime);
    Date endDate = new Date(getObservationDate().getTime() + end);
    log.debug("endDate " + endDate.toString());

    if (endDate.before(startDate)) {
        addActionError("Start Time Must Be Before End Time");
    } else {/*from  w  w  w. j a va 2s.  c  om*/
        Map<String, Object> hm = new HashMap<String, Object>();
        hm.put("observationStartTime", startDate);
        hm.put("observationEndTime", endDate);
        hm.put("vehicleFk", vehicleFk);
        hm.put("instructorFk", instructorFk);
        hm.put("classroomFk", classroomPk);
        hm.put("branchFk", branchFk);
        for (int x = 0; x < studentArray.size(); x++) {
            hm.put("studentFk", studentArray.get(x));
            getStudentService().insertObservation(hm);
        }
    }

    if (hasErrors()) {
        return INPUT;
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append("<br/>Observation Times Added For ");
        sb.append(studentArray.size());
        if (studentArray.size() == 1) {
            sb.append(" Student");
        } else {
            sb.append(" Students");
        }
        Collection<Object> col = new ArrayList<Object>();
        col.add(sb);
        setThirdPartyAjaxMessages(col);
        return SUCCESS;
    }
}

From source file:gov.utah.dts.sdc.actions.BaseThirdPartyStudentAction.java

public String insertBtwTime() throws Exception {
    log.debug("insertBtwTime");
    //log.debug("observationDate truncated "+ truncateDate(getObservationDate()));
    int start = decodeTime(behindTheWheelStartTime);
    Date startDate = new Date(getBehindTheWheelDate().getTime() + start);
    log.debug("startDate " + startDate.toString());

    int end = decodeTime(behindTheWheelEndTime);
    Date endDate = new Date(getBehindTheWheelDate().getTime() + end);
    log.debug("endDate " + endDate.toString());

    if (endDate.before(startDate)) {
        addActionError("Start Time Must Be Before End Time");
    } else {//w  ww .j a va2s .c o m
        Map<String, Object> hm = new HashMap<String, Object>();
        hm.put("btwStartTime", startDate);
        hm.put("btwEndTime", endDate);
        hm.put("vehicleFk", vehicleFk);
        hm.put("instructorFk", instructorFk);
        hm.put("classroomFk", classroomPk);
        hm.put("branchFk", branchFk);
        for (int x = 0; x < studentArray.size(); x++) {
            hm.put("studentFk", studentArray.get(x));
            getStudentService().insertBehindTheWheel(hm);
        }
    }

    if (hasErrors()) {
        return INPUT;
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append("<br/>Behind The Wheel Times Added For ");
        sb.append(studentArray.size());
        if (studentArray.size() == 1) {
            sb.append(" Student");
        } else {
            sb.append(" Students");
        }
        Collection<Object> col = new ArrayList<Object>();
        col.add(sb);
        setThirdPartyAjaxMessages(col);
        return SUCCESS;
    }
}

From source file:org.openmrs.module.appointmentscheduling.web.controller.AppointmentFormController.java

@ModelAttribute("availableTimes")
public List<TimeSlot> getAvailableTimes(ModelMap model, HttpServletRequest request, Appointment appointment,
        @RequestParam(value = "fromDate", required = false) Date fromDate,
        @RequestParam(value = "toDate", required = false) Date toDate,
        @RequestParam(value = "providerSelect", required = false) Provider provider,
        @RequestParam(value = "locationId", required = false) Location location,
        @RequestParam(value = "includeFull", required = false) String includeFull,
        @RequestParam(value = "flow", required = false) String flow) {
    AppointmentType appointmentType = appointment.getAppointmentType();
    if (appointmentType == null || (fromDate != null && toDate != null && !fromDate.before(toDate)))
        return null;
    //If its a walk-in flow change the start date to current time and end date to the end of today (23:59:59.999)
    if (flow != null) {
        fromDate = Calendar.getInstance().getTime();
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 999);
        toDate = cal.getTime();/*from  w w  w .  jav  a  2s  .c  o m*/
    }

    try {
        List<TimeSlot> availableTimeSlots = null;

        //No need to include full slots
        if (includeFull == null || !Context.hasPrivilege(AppointmentUtils.PRIV_SQUEEZE_APPOINTMENTS)) {
            availableTimeSlots = Context.getService(AppointmentService.class)
                    .getTimeSlotsByConstraints(appointmentType, fromDate, toDate, provider, location);
            TimeSlot currentSelectedSlot = appointment.getTimeSlot();
            //The appointment time slot should be selected from the latest list
            if (currentSelectedSlot != null && !availableTimeSlots.contains(currentSelectedSlot))
                appointment.setTimeSlot(null);
        }

        //Include full and indicate which are full using the model attribute fullSlots
        else {
            availableTimeSlots = Context.getService(AppointmentService.class)
                    .getTimeSlotsByConstraintsIncludingFull(appointmentType, fromDate, toDate, provider,
                            location);
            List<TimeSlot> fullTimeSlots = new LinkedList<TimeSlot>();
            Map<Integer, Integer> overdueTimes = new HashMap<Integer, Integer>();

            Integer typeDuration = appointmentType.getDuration();

            Iterator<TimeSlot> iterator = availableTimeSlots.iterator();
            while (iterator.hasNext()) {
                TimeSlot slot = iterator.next();
                Integer timeLeft = Context.getService(AppointmentService.class).getTimeLeftInTimeSlot(slot);
                if (timeLeft < typeDuration) {
                    fullTimeSlots.add(slot);
                    overdueTimes.put(slot.getId(), timeLeft);
                    iterator.remove();
                }
            }

            model.put("fullSlots", fullTimeSlots);
            model.put("overdueTimes", overdueTimes);
        }

        return availableTimeSlots;
    } catch (Exception ex) {
        return null;
    }
}