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:dk.netarkivet.harvester.datamodel.Job.java

/**
 * Set the actual time when this job was stopped/completed. Sends a notification, if actualStop is set to a time
 * before actualStart.//from w  ww  .j  a va  2 s  .co  m
 *
 * @param actualStop A Date object representing the time when this job was stopped.
 * @throws ArgumentNotValid
 */
public void setActualStop(Date actualStop) throws ArgumentNotValid {
    ArgumentNotValid.checkNotNull(actualStop, "actualStop");
    if (actualStart == null) {
        log.warn("Job(" + getJobID() + "): actualStart should be defined before setting actualStop");
    } else if (actualStop.before(actualStart)) {
        log.warn("Job(" + getJobID() + "): actualStop (" + actualStop + ") is before actualStart: "
                + actualStart);
    }
    this.actualStop = (Date) actualStop.clone();
}

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

public String updateTrainingTime() 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 {/*  w w  w .  ja  va 2s .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);
        hm.put("studentFk", studentPk);
        hm.put("timePk", timePk);
        hm.put("training_userid", ((Person) getSession().get(Constants.USER_KEY)).getEmail());
        hm.put("training_datestamp", new Date());
        getStudentService().updateTraining(hm);
    }

    if (hasErrors()) {
        return INPUT;
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append("<br/>Training Times Updated For Student");
        Collection<Object> col = new ArrayList<Object>();
        col.add(sb);
        setCommercialAjaxMessages(col);
        return SUCCESS;
    }
}

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

public String updateObservationTime() throws Exception {
    log.debug("updateObservationTime");
    log.debug("updateObservationTime StartTime " + observationStartTime);
    int start = decodeTime(observationStartTime);
    log.debug("updateObservationTime StartTime decoded");
    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 {/* w  w w  . j a  va 2s.  c o m*/
        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);
        hm.put("studentFk", studentPk);
        hm.put("timePk", timePk);
        hm.put("observation_userid", ((Person) getSession().get(Constants.USER_KEY)).getEmail());
        hm.put("observation_datestamp", new Date());
        getStudentService().updateObservation(hm);
    }

    if (hasErrors()) {
        return INPUT;
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append("<br/>Observation Times Updated For Student");
        Collection<Object> col = new ArrayList<Object>();
        col.add(sb);
        setCommercialAjaxMessages(col);
        return SUCCESS;
    }
}

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

public String updateBTWTime() throws Exception {
    log.debug("updateBtwTime");
    // 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 {/*ww  w.  j a v  a 2  s  . 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("branchFk", branchFk);
        hm.put("studentFk", studentPk);
        hm.put("timePk", timePk);
        hm.put("btw_userid", ((Person) getSession().get(Constants.USER_KEY)).getEmail());
        hm.put("btw_datestamp", new Date());
        getStudentService().updateBehindTheWheel(hm);
    }

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

From source file:eu.europa.esig.dss.validation.process.AdESTValidation.java

private Date getLatestTimestampProductionDate(final List<XmlDom> timestamps,
        final TimestampType selectedTimestampType) {

    Date latestProductionTime = null;
    for (final XmlDom timestamp : timestamps) {

        final String timestampType = timestamp.getValue("./@Type");
        if (!selectedTimestampType.name().equals(timestampType)) {
            continue;
        }//w  ww.  j  ava  2s.  c o m
        final Date productionTime = timestamp.getTimeValue("./ProductionTime/text()");
        if ((latestProductionTime == null) || latestProductionTime.before(productionTime)) {

            latestProductionTime = productionTime;
        }
    }
    return latestProductionTime;
}

From source file:gov.utah.dts.sdc.actions.BaseCommercialStudentAction.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 ww.  j a v a2s  .co  m
        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);
        hm.put("observation_userid", ((Person) getSession().get(Constants.USER_KEY)).getEmail());
        hm.put("observation_datestamp", new Date());
        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);
        setCommercialAjaxMessages(col);
        return SUCCESS;
    }
}

From source file:gov.utah.dts.sdc.actions.BaseCommercialStudentAction.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   www . j  a v  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);
        hm.put("training_userid", ((Person) getSession().get(Constants.USER_KEY)).getEmail());
        hm.put("training_datestamp", new Date());
        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);
        setCommercialAjaxMessages(col);
        return SUCCESS;
    }
}

From source file:gov.utah.dts.sdc.actions.BaseCommercialStudentAction.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 {/*from   w  w w . java  2  s. 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);
        hm.put("btw_userid", ((Person) getSession().get(Constants.USER_KEY)).getEmail());
        hm.put("btw_datestamp", new Date());
        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);
        setCommercialAjaxMessages(col);
        return SUCCESS;
    }
}

From source file:fragment.web.BillingControllerTest.java

@Test
public void testTerminateSubscription() {
    Tenant tenant = createTestTenant(accountTypeDAO.getDefaultRegistrationAccountType());
    tenant.setState(com.vmops.model.Tenant.State.ACTIVE);
    tenant.setAccountType(accountTypeDAO.getDefaultRegistrationAccountType());
    User user = createTestUserInTenant(tenant);
    tenantService.setOwner(tenant, user);
    List<ProductBundle> bundles = productBundleService.listProductBundles(0, 0);
    ProductBundle nonVmBundle = null;//w  ww .ja  v a 2 s.  c om
    for (ProductBundle bundle : bundles) {
        if (!bundle.getResourceType().getResourceTypeName().equals("VirtualMachine")) {
            nonVmBundle = bundle;
            break;
        }
    }
    tenant.getOwner().setEnabled(true);
    Subscription subscription = subscriptionService.createSubscription(tenant.getOwner(), nonVmBundle, null,
            null, false, false, null, new HashMap<String, String>());
    Assert.assertNotNull(subscription);
    SubscriptionHandle subscriptionHandle = new SubscriptionHandle(subscription, "",
            subscription.getServiceInstance().getUuid(), "VirtualMachine", user, State.ACTIVE, null, null,
            "TestVM");
    subscription.addHandle(subscriptionHandle);
    subscriptionDAO.merge(subscription);
    prepareMockForTerminateAndCancelSubscriptionDetails(tenant.getOwner());
    Date timeBeforeTermination = new Date();
    Subscription sub = controller.terminateSubscription(subscription.getParam(), map);
    Assert.assertNotNull(sub);
    Assert.assertTrue((timeBeforeTermination.before(sub.getTerminationDateWithTime())
            || timeBeforeTermination.equals(sub.getTerminationDateWithTime())));
    Assert.assertEquals(sub.getState().name(), new String("EXPIRED"));
    Assert.assertEquals(State.TERMINATED, sub.getHandle().getState());

}