Example usage for java.util Date after

List of usage examples for java.util Date after

Introduction

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

Prototype

public boolean after(Date when) 

Source Link

Document

Tests if this date is after the specified date.

Usage

From source file:gda.data.metadata.icat.XMLIcat.java

@Override
protected String getValue(String visitIDFilter, String userNameFilter, String accessName) throws Exception {

    String filepath = "file:" + LocalProperties.get(URL_PROP);
    Resource xmlfile = new FileSystemResourceLoader().getResource(filepath);
    XmlBeanFactory bf = new XmlBeanFactory(xmlfile);

    long tolerance = LocalProperties.getAsInt(SHIFT_TOL_PROP, 1440);

    // if not filtering on visit ID
    if (visitIDFilter == null || visitIDFilter.isEmpty()) {

        //loop over all the beans
        String values = "";
        Map<String, XMLIcatEntry> beans = bf.getBeansOfType(XMLIcatEntry.class);
        for (XMLIcatEntry bean : beans.values()) {
            // filter on username
            String names[] = bean.getUsernames().split(",");
            if (ArrayUtils.contains(names, userNameFilter)) {

                // filter on date
                Date now;
                if (operatingDate != null) {
                    now = operatingDate;
                } else {
                    now = new Date();
                }/* w  w  w.j  ava 2s . co m*/

                Date start = formatter.parse(bean.getExperimentStart());
                Date end = formatter.parse(bean.getExperimentStart());
                start.setTime(start.getTime() - tolerance * 60000);// tolerance is in minutes but getTime returns in
                // ms
                end.setTime(end.getTime() + tolerance * 60000); // tolerance is in minutes but getTime returns in ms

                if (now.after(start) && now.before(end)) {

                    // add to return string
                    try {
                        if (values.isEmpty()) {
                            values = BeanUtils.getProperty(bean, accessName);
                        } else {
                            values += "," + BeanUtils.getProperty(bean, accessName);
                        }
                    } catch (Exception e) {
                        logger.warn("Exception trying to get property " + accessName + " from bean.", e);
                    }
                }
            }
        }

        // return the values string
        if (values.isEmpty()) {
            return null;
        }
        return values;
    }

    // else find the experiment for that visit and get its property
    XMLIcatEntry visit = bf.getBean(visitIDFilter, XMLIcatEntry.class);
    String names[] = visit.getUsernames().split(",");
    if (ArrayUtils.contains(names, userNameFilter)) {
        try {
            return BeanUtils.getProperty(visit, accessName);
        } catch (Exception e) {
            logger.warn("Exception trying to get property " + accessName + " from bean.", e);
        }
    }

    // else 
    return null;

}

From source file:com.pearson.dashboard.util.Util.java

public static Map<String, List<String>> getIteration(Configuration configuration, String projectId)
        throws IOException, ParseException, URISyntaxException {
    RallyRestApi restApi = loginRally(configuration);
    Map<String, List<String>> testSetsInformation = new HashMap<String, List<String>>();
    QueryRequest iterationRequest = new QueryRequest("Iteration");
    iterationRequest.setProject("/project/" + projectId);
    iterationRequest.setLimit(2000);//from  w  w w. ja  v a  2 s .  c  o m
    QueryResponse iterationResponse = restApi.query(iterationRequest);
    JsonArray iterationArray = iterationResponse.getResults();
    QueryFilter queryFilter = null;
    for (int i = 0; i < iterationArray.size(); i++) {
        JsonElement elements = iterationArray.get(i);
        JsonObject object = elements.getAsJsonObject();
        String ref = object.get("_ref").getAsString();
        ref = ref.substring(ref.indexOf("/iteration/"));
        ref = ref.replace(".js", "");
        DateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd");
        String strStartDate = object.get("StartDate").getAsString().substring(0, 10);
        Date startDate = (Date) formatter1.parse(strStartDate);
        String strEndDate = object.get("EndDate").getAsString().substring(0, 10);
        Date endDate = (Date) formatter1.parse(strEndDate);
        Date dateNow = new Date();
        if (dateNow.after(startDate) && dateNow.before(endDate)) {
            if (queryFilter == null) {
                queryFilter = new QueryFilter("Iteration", "=", ref);
            } else {
                queryFilter = queryFilter.or(new QueryFilter("Iteration", "=", ref));
            }
        }
    }
    if (queryFilter != null) {
        QueryRequest testSetRequest = new QueryRequest("TestSet");
        testSetRequest.setQueryFilter(queryFilter);
        String wsapiVersion = "1.43";
        restApi.setWsapiVersion(wsapiVersion);
        testSetRequest.setProject("/project/" + projectId);
        testSetRequest.setScopedDown(true);
        QueryResponse testSetQueryResponse = restApi.query(testSetRequest);
        List<String> iosTestSetList = new ArrayList<String>();
        List<String> winTestSetList = new ArrayList<String>();
        for (int i = 0; i < testSetQueryResponse.getResults().size(); i++) {
            JsonObject testSetJsonObject = testSetQueryResponse.getResults().get(i).getAsJsonObject();
            String testSetId = testSetJsonObject.get("FormattedID").getAsString();
            String testSetName = testSetJsonObject.get("Name").getAsString();
            if (testSetName.toUpperCase().contains("EOS")) {
                if (testSetName.toUpperCase().contains("WIN")) {
                    winTestSetList.add(testSetId);
                } else {
                    iosTestSetList.add(testSetId);
                }
            }

        }
        testSetsInformation.put("IOS", iosTestSetList);
        testSetsInformation.put("WIN", winTestSetList);
    }
    return testSetsInformation;
}

From source file:com.virtusa.akura.student.controller.StudentAttendenceController.java

/**
 * generate student attendance detail for given time range in studentTemplate. map key contains date and
 * value contains attendance status as AttendeceStatus object.
 * //w w  w .  jav  a  2s  .  c o  m
 * @param studentTemplate time rage as template
 * @param studentId for given studentId(primary key)
 * @param modelMap - a hash map related to the student attendance.
 * @return map with attendant status
 * @throws AkuraAppException when exception occurs
 */
private Map<String, AttendeceStatus> getAllAttendanceStatus(StudentWiseSwipInOutTemplate studentTemplate,
        int studentId, ModelMap modelMap) throws AkuraAppException {

    Date from = DateUtil.getParseDate(studentTemplate.getDateFrom());
    Date to = DateUtil.getParseDate(studentTemplate.getDateTo());
    Map<String, AttendeceStatus> allDays = new TreeMap<String, AttendeceStatus>();

    // if the start date of the student is less than the attendance search from date,
    // save or edit.
    Date startedDate = studentService.getStudentStartedDate(studentId);

    if (startedDate != null && from.after(startedDate) || (startedDate != null && startedDate.equals(from))) {

        // map contains all the days with absent in default
        allDays = getDaysWithoutHolydays(from, to);

        // to overwrite the "allDays" map values for absent with a reason
        List<StudentLeave> leaveList = studentService.findAlreadyExistLeave(studentId, from, to);
        for (StudentLeave leave : leaveList) {
            Date leaveFrom = leave.getFromDate();
            Date leaveTo = leave.getToDate();

            for (Entry<String, AttendeceStatus> entry : allDays.entrySet()) {
                Date day = DateUtil.getParseDate(entry.getKey());
                if (day.equals(leaveFrom) || day.equals(leaveTo)
                        || (day.after(leaveFrom) && day.before(leaveTo))) {
                    entry.getValue().setDescription(leave.getReason());
                }
            }
        }

        // to overwrite the "allDays" map values for attended days
        List<DailyStudentAttendance> dalyAttendList = dailyAttendanceService.getAttendanceBettween(studentId,
                from, to);
        for (DailyStudentAttendance dalyAttend : dalyAttendList) {

            String dayKey = DateUtil.getFormatDate(dalyAttend.getDate());
            if (allDays.containsKey(dayKey)) {
                AttendeceStatus attendStatus = allDays.get(dayKey);
                attendStatus.setAbsent(false);
                attendStatus.setTimeIn(dalyAttend.getTimeIn());
                attendStatus.setTimeOut(dalyAttend.getTimeOut());
            }
        }
    } else {
        String message = new ErrorMsgLoader().getErrorMessage(STUDENT_FIRST_DATE_ATTENDANCE_ERROR);
        modelMap.addAttribute(MESSAGE, message);
    }
    return allDays;
}

From source file:com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean.java

private void checkRange(String[] formFieldNames) {
    if (!this.isAttributeFilter() || null != this.getFormFieldErrors() || null == this.getFormFieldValues()
            || this.getFormFieldValues().size() < 2)
        return;/*from  w  ww.j  a va  2s. c  o m*/
    boolean check = false;
    if (this.getAttribute() instanceof DateAttribute) {
        Date start = DateConverter.parseDate(this.getFormFieldValues().get(formFieldNames[0]),
                this.getDateFormat());
        Date end = DateConverter.parseDate(this.getFormFieldValues().get(formFieldNames[1]),
                this.getDateFormat());
        check = (!start.equals(end) && start.after(end));
    } else if (this.getAttribute() instanceof NumberAttribute) {
        Integer start = Integer.parseInt(this.getFormFieldValues().get(formFieldNames[0]));
        Integer end = Integer.parseInt(this.getFormFieldValues().get(formFieldNames[1]));
        check = (!start.equals(end) && start.intValue() > end.intValue());
    }
    if (check) {
        this.setFormFieldErrors(new HashMap<String, AttributeFormFieldError>(2));
        AttributeFormFieldError error = new AttributeFormFieldError(this.getAttribute().getName(),
                formFieldNames[1], AttributeFormFieldError.INVALID_RANGE_KEY, null);
        this.getFormFieldErrors().put(formFieldNames[1], error);
    }
}

From source file:de.innovationgate.wgpublisher.WGPDeployer.java

public Date getLastChangedOrDeployed(WGDatabase db) {

    String designDBKey = _core.getDesignDatabaseKey(db);

    Date lastDeployed = getLastDeployed(designDBKey);
    Date lastChanged = db.getLastChanged();
    if (lastDeployed == null || (lastChanged != null && lastChanged.after(lastDeployed))) {
        return lastChanged;
    } else {//from   w  ww . j av  a 2s . c  om
        return lastDeployed;
    }

}

From source file:com.virtusa.akura.student.controller.StudentLeaveController.java

/**
 * This method is to Add/Edit/Delete student leave.
 * /*from  w  w  w .  j  a  v a2s .  c  om*/
 * @param studentLeave - {@link StudentLeave}
 * @param bindingResult - {@link BindingResult}
 * @param request - {@link HttpServletRequest}
 * @param model - {@link ModelMap}
 * @param session - {@link HttpSession}
 * @return the name of the view.
 * @throws AkuraAppException - The exception details that occurred when processing.
 */
@RequestMapping(value = REQ_MAP_VALUE_SAVEORUPDATE, method = RequestMethod.POST)
public String saveOrUpdateStudentLeave(@ModelAttribute(MODEL_ATT_STUDENT_LEAVE) StudentLeave studentLeave,
        BindingResult bindingResult, HttpServletRequest request, ModelMap model, HttpSession session)
        throws AkuraAppException {

    studentLeaveValidator.validate(studentLeave, bindingResult);

    if (request.getParameter(ATTENDANCE_PAGE).equals(TRUE)) {
        model.addAttribute(ATTENDANCE_PAGE, TRUE);
    } else {
        model.addAttribute(ATTENDANCE_PAGE, FALSE);
    }

    if (bindingResult.hasErrors()) {
        setRatingValue(model, session);
        return VIEW_GET_STUDENT_LEAVE;
    } else {

        Date dateFrom = studentLeave.getFromDate();
        int studentId = (Integer) session.getAttribute(STUDENT_ID);

        // if the first date of the student is less than the start date of the leave,
        // save or edit.
        Date startedDate = studentService.getStudentStartedDate(studentId);

        if (startedDate != null && dateFrom.after(startedDate)
                || (startedDate != null && startedDate.equals(dateFrom))) {
            Date dateTo = studentLeave.getToDate();
            Calendar fromDate = Calendar.getInstance();
            fromDate.setTime(dateFrom);
            Calendar toDate = Calendar.getInstance();
            toDate.setTime(dateTo);

            List<Holiday> holidayList = getHolidayList(dateFrom, dateTo);

            int holidayCount = HolidayUtil.countHolidays(fromDate, toDate, holidayList);
            int daysCount = StaticDataUtil.daysBetween(dateFrom, dateTo) - holidayCount;

            if (daysCount > MAXIMUM_LEAVE_DAYS) {

                if (!studentLeave.getCertificategiven()) {
                    String message = new ErrorMsgLoader().getErrorMessage(LEAVE_ERROR);
                    model.addAttribute(MESSAGE, message);
                    return VIEW_GET_STUDENT_LEAVE;
                }

            } else if (daysCount == 0) {
                String message = new ErrorMsgLoader().getErrorMessage(LEAVE_ON_HOLIDAY_DATES);
                model.addAttribute(MESSAGE, message);
                return VIEW_GET_STUDENT_LEAVE;
            }
            String reason = StaticDataUtil.removeExtraWhiteSpace(studentLeave.getReason());

            List<StudentLeave> existLeave = studentService.findAlreadyExistLeave(studentId, dateFrom, dateTo);

            if ((!existLeave.isEmpty() && studentLeave.getStudentLeaveId() == 0) || (!existLeave.isEmpty()
                    && existLeave.get(0).getStudentLeaveId() != studentLeave.getStudentLeaveId())) {
                model.addAttribute(MESSAGE, new ErrorMsgLoader().getErrorMessage(ALREADY_EXIST));
                return VIEW_GET_STUDENT_LEAVE;
            } else if (studentService.isPresentDay(studentId, dateFrom, dateTo)) {
                String message = new ErrorMsgLoader().getErrorMessage(STUDENT_PRESENT_DATE_ERROR);
                model.addAttribute(MESSAGE, message);
                return VIEW_GET_STUDENT_LEAVE;
            } else {
                studentLeave.setStudentId(studentId);
                studentLeave.setReason(reason);
                studentLeave.setNoOfDays(daysCount);

                if (studentLeave.getStudentLeaveId() == 0) {
                    studentService.createStudentLeave(studentLeave);
                } else {
                    studentService.updateStudentLeave(studentLeave);
                }
            }
        } else {
            if (startedDate != null) {
                String message = new ErrorMsgLoader().getErrorMessage(STUDENT_FIRST_DATE_ERROR);
                model.addAttribute(MESSAGE, message);
                return VIEW_GET_STUDENT_LEAVE;
            }
        }
    }

    return VIEW_POST_MANAGE_STUDENT_LEAVE;
}

From source file:ch.entwine.weblounge.common.impl.request.WebloungeResponseImpl.java

/**
 * {@inheritDoc}/*from  w w w .  ja v  a2  s  . co  m*/
 * 
 * @see ch.entwine.weblounge.common.request.WebloungeResponse#setModificationDate(Date)
 */
@Override
public Date setModificationDate(Date modificationDate) {
    if (modificationDate == null)
        return this.modificationDate;
    this.modificationDate = modificationDate.after(this.modificationDate) ? modificationDate
            : this.modificationDate;
    if (cacheHandle == null)
        return this.modificationDate;
    CacheHandle hdl = cacheHandle.get();
    if (hdl == null)
        return this.modificationDate;
    return hdl.setModificationDate(modificationDate);
}

From source file:com.enonic.cms.core.content.ContentVersionEntity.java

public int getState(Date now) {
    int state;//from   ww  w.  j  a  v a 2  s.com

    if (isApproved() && isMainVersion()) {
        Date from = content.getAvailableFrom();
        Date to = content.getAvailableTo();

        if (from == null && to == null) {
            state = ContentStatus.APPROVED.getKey();
        } else if (from == null) {
            if (now.after(to) || now.equals(to)) {
                state = ContentVersionEntity.STATE_PUBLISH_EXPIRED;
            } else {
                state = ContentStatus.APPROVED.getKey();
            }
        } else if (from.after(now)) {
            state = ContentVersionEntity.STATE_PUBLISH_WAITING;
        } else { // from.before(now) == true
            if (to == null || to.after(now)) {
                state = ContentVersionEntity.STATE_PUBLISHED;
            } else {
                state = ContentVersionEntity.STATE_PUBLISH_EXPIRED;
            }
        }
    } else {
        state = status;
    }

    return state;
}

From source file:net.sourceforge.vulcan.web.ProjectFileServlet.java

/**
 * @return <code>true</code> if the file has been modified more recently and should be retransmitted
 * <br> <code>false</code> if the file has not been modified.
 *//*from   ww  w  . ja  v  a  2s . c om*/
private boolean checkModifiedSinceHeader(HttpServletRequest request, Date lastModified) {
    if (!cacheEnabled) {
        return true;
    }

    lastModified = new Date((lastModified.getTime() / 1000) * 1000);

    final String header = request.getHeader("If-Modified-Since");

    if (isBlank(header)) {
        return true;
    }

    synchronized (HTTP_DATE_FORMAT) {
        try {
            final Date lastChecked = HTTP_DATE_FORMAT.parse(header);

            return lastModified.after(lastChecked);
        } catch (ParseException e) {
            return true;
        }
    }
}

From source file:com.nridge.core.app.mgr.ServiceTimer.java

/**
 * Returns <i>true</i> if the time for a full service wake-up has
 * arrived.//from   w ww .  j ava  2s .  c o  m
 *
 * @return <i>true</i> or <i>false</i>
 */
public boolean isTimeForFullService() {
    boolean isTime = false;
    Logger appLogger = mAppMgr.getLogger(this, "isTimeForFullService");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    if (mIsFirstService) {
        Date tsNow = new Date();
        String msgStr = String.format("The full service time of '%s' has arrived (first time event).",
                Field.dateValueFormatted(tsNow, Field.FORMAT_DATETIME_DEFAULT));
        appLogger.debug(msgStr);

        isTime = true;
        mIsFirstService = false;
    } else {
        Date tsNow = new Date();
        Date tsFullService = getNextTS("run_full_interval", getLastFullServiceTS());
        if (tsNow.after(tsFullService)) {
            String msgStr = String.format("The full service time of '%s' has arrived.",
                    Field.dateValueFormatted(tsFullService, Field.FORMAT_DATETIME_DEFAULT));
            appLogger.debug(msgStr);
            isTime = true;
        }
    }

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);

    return isTime;
}