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:gov.nasa.ensemble.core.jscience.csvxml.ProfileLoader.java

private void loadDataFromThisPointInStream(InputStream stream) throws ProfileLoadingException {

    try {//w ww .j  ava  2  s .c o m
        List<DataPoint>[] dataPointsForEachProfile = new ArrayList[profileAndMetadataInXmlOrder.size()];
        for (int i = 0; i < dataPointsForEachProfile.length; i++) {
            dataPointsForEachProfile[i] = new ArrayList<DataPoint>();
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
        skipCDATA(reader);
        List<String> headers = CSVUtilities.parseCSVLine(reader, true);
        validateHeaderRow(headers);
        profileAndMetadataInCsvOrder = reorderProfilesAndAddMetadata(headers);
        List<String> currentRow = headers;
        Date prevDate = null;
        boolean rowsWereOutOfTimeOrder = false;
        while (true) { // loop over rows, adding to add profiles (except where values are omitted in a row).
            currentRow = CSVUtilities.parseCSVLine(reader, true);
            if (currentRow.size() > 0 && currentRow.get(0).trim().startsWith(END_OF_CSV_LINE)) {
                break; // end of data
            }
            if (currentRow.size() != profileAndMetadataInXmlOrder.size() + 1) {
                throw new ProfileLoadingException("Row has " + currentRow.size() + " elements instead of "
                        + (profileAndMetadataInXmlOrder.size() + 1) + ": " + currentRow);
            }
            Date date = parseDateCell(currentRow.get(0));
            if (prevDate != null && prevDate.after(date)) {
                rowsWereOutOfTimeOrder = true;
            }
            prevDate = date;
            for (int i = 0, column = 1; i < dataPointsForEachProfile.length; i++, column++) {
                ProfileAndMetadata profileAndMetadata = profileAndMetadataInCsvOrder[i];
                Datatype datatype = profileAndMetadata.getDatatype();
                Object defaultValue = profileAndMetadata.getDefaultValue();
                String cellContents = currentRow.get(column);
                if (!isEmpty(cellContents, datatype)) {
                    dataPointsForEachProfile[i]
                            .add(new DataPointImpl(date, parseValueCell(cellContents, datatype)));
                } else if (defaultValue != null) {
                    dataPointsForEachProfile[i].add(new DataPointImpl(date, defaultValue));
                }
            }
        }
        int i = 0;
        for (ProfileAndMetadata profileEtc : profileAndMetadataInCsvOrder) {
            List<DataPoint> dataPoints = dataPointsForEachProfile[i++];
            if (rowsWereOutOfTimeOrder) {
                Collections.sort(dataPoints, DataPoint.DEFAULT_COMPARATOR);
            }
            profileEtc.getProfile().setDataPoints(dataPoints);
        }
    } catch (IOException e) {
        throw new ProfileLoadingException("I/O error: " + e);
    } finally {
        if (sourceStream == null) {
            IOUtils.closeQuietly(stream);
        }
    }
}

From source file:com.relecotech.common.controller.AcceptParameterController.java

@RequestMapping(value = "/{name}", method = RequestMethod.GET)
//public String getMovie(@PathVariable String name, ModelMap model) {
public @ResponseBody ModelAndView getParameter(@PathVariable String name) throws ParserConfigurationException {
    //String param =name;
    try {//from  w w  w. j a va2  s.c o m
        Map<String, String> valueMap = new HashMap<String, String>();
        String[] data = name.split("&");
        for (String str : data) {
            String[] mapPair = str.split("=");
            valueMap.put(mapPair[0], mapPair[1]);
        }
        String logoutUrl = "https://" + valueMap.get("URL") + ".com";
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        SAMLCredential credential = (SAMLCredential) authentication.getCredentials();
        TimeZone timeZone = TimeZone.getTimeZone(valueMap.get("timeZone").replace("*", "/"));

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm a");
        dateFormat.setTimeZone(timeZone);

        Calendar calobj = Calendar.getInstance(timeZone);
        String SystemCurrentTime = dateFormat.format(calobj.getTime());
        Date SystemCurrentDateTime = dateFormat.parse(SystemCurrentTime);
        // Date SystemCurrentDateTime = calobj.getTime();

        //SFDC Meeting DATE/TIME 
        String sfdcMeetingTime = valueMap.get("d").replace("*", "/");
        System.out.println("sfdcMeetingTime=" + sfdcMeetingTime);
        Date sfdcMeetingDateTime = dateFormat.parse(sfdcMeetingTime);
        //TIME Before Meeting can satarted 
        Date sfdcMeetingBeforeDateTime = dateFormat
                .parse(AddSubtractTime.getSubtractedTime(sfdcMeetingTime, timeZone));
        //TIME after Meeting cannot be satarted 
        Date sfdcMeetingAfterDateTime = dateFormat
                .parse(AddSubtractTime.getAddedTime(sfdcMeetingTime, timeZone));

        System.out.println("SystemCurrentDateTime=" + SystemCurrentDateTime);
        System.out.println("sfdcMeetingDateTime=" + sfdcMeetingDateTime);
        System.out.println("sfdcMeetingAfterDateTime=" + sfdcMeetingAfterDateTime);
        System.out.println("sfdcMeetingBeforeDateTime=" + sfdcMeetingBeforeDateTime);
        if (SystemCurrentDateTime.after(sfdcMeetingBeforeDateTime)
                && SystemCurrentDateTime.before(sfdcMeetingAfterDateTime)) {
            APIGenerator aPIGenerator = new APIGenerator();
            System.out.println("converted id=" + SalesforceIDConverter.convertID(valueMap.get("code")));
            System.out.println((credential.getAttributeAsString("ContactId")));
            if (valueMap.get("code")
                    .matches(SalesforceIDConverter.convertID(credential.getAttributeAsString("ContactId")))) {

                System.out.println("valuemap=" + valueMap);

                System.out.println("logout url=" + logoutUrl);
                String create = "attendeePW=ap" + "&meetingID=" + valueMap.get("name") + "&moderatorPW=newuser"
                        + "&name=" + valueMap.get("name") + "&logoutURL=" + logoutUrl;
                System.out.println("create parameter=" + create);
                XmlParser.runAPI(aPIGenerator.createAPI("create", create));
                // String join = "fullName=" + valueMap.get("fullName") + "&meetingID=" + valueMap.get("meetingID") + "&password=newuser";
                String join = "fullName=" + credential.getAttributeAsString("username") + "&meetingID="
                        + valueMap.get("name") + "&password=newuser";
                System.out.println("joinparam=" + join);
                aPIGenerator.createAPI("join", join);
                return new ModelAndView("redirect:" + aPIGenerator.apiWithChecksum);

            } else {
                Map<String, String> responceMap = XmlParser.runAPI(
                        aPIGenerator.createAPI("isMeetingRunning", "meetingID=" + valueMap.get("name")));
                String join = "fullName=" + credential.getAttributeAsString("username") + "&meetingID="
                        + valueMap.get("name") + "&password=ap";
                if (responceMap.get("running").matches("true")) {

                    aPIGenerator.createAPI("join", join);
                    return new ModelAndView("redirect:" + aPIGenerator.apiWithChecksum);
                } else {
                    String student = "<center>  <h1>Wait! Presenter has not joined meeting yet!</h1>\n"
                            //                                +"<img src=\"${pageContext.request.contextPath}/images/bbbtime.jpg\" style=\"width:304px;height:228px\"/> "
                            + "     <h2>\n" + "           Please try after few minutes.\n" + "        \n"
                            + "<br>Meeting Date/Time:" + dateFormat.format(sfdcMeetingDateTime) + "<br><a href="
                            + logoutUrl + ">Back</a>" + "    </h2></center> ";
                    // return new ModelAndView("redirect:" + "/student.jsp");
                    return new ModelAndView("student", "student", student);
                }
            }

        } else {
            //                
            if (SystemCurrentDateTime.compareTo(sfdcMeetingDateTime) == -1) {

                String wait = "<center> <h1>Too Early for Meeting!</h1><br></center>\n"
                        //                             +"<img src=\"${pageContext.request.contextPath}/images/bbbtime.jpg\" style=\"width:304px;height:228px\"/> "
                        + "  <center>  <h2>Meeting is not yet open.<br>\n"
                        + "  Please check meeting schedule time. \n<br>" + "<br>Meeting Date/Time:"
                        + dateFormat.format(sfdcMeetingDateTime) + "</h2><h3>System Current Date/Time:"
                        + dateFormat.format(SystemCurrentDateTime)
                        + "<br>*Meeting will open 15 minutes before scheduled time</h3><a href=" + logoutUrl
                        + ">Back</a>" + "  </center> ";
                return new ModelAndView("wait", "wait", wait);
            }
            //for Past Date
            if (SystemCurrentDateTime.compareTo(sfdcMeetingDateTime) == 1) {
                String wait = "<center> <h1>Meeting is Over!</h1><br></center>\n"
                        //                             +"<img src=\"${pageContext.request.contextPath}/images/bbbtime.jpg\" style=\"width:304px;height:228px\"/> "
                        + "  <center>  <h2>Meeting can not open.<br>\n"
                        + "        Meeting was scheduled on - \n<br>" + "<br>Meeting Date/Time:"
                        + dateFormat.format(sfdcMeetingDateTime) + "</h2><h3><br>System Current Date/Time:"
                        + dateFormat.format(SystemCurrentDateTime) + "<br><a href=" + logoutUrl + ">Back</a>"
                        + "  </h3>  </center> ";
                return new ModelAndView("wait", "wait", wait);

            }
            //                
        }

    } catch (Exception ex) {
        System.out.println("Exception=" + ex);
    }

    return null;
}

From source file:ddf.security.assertion.impl.SecurityAssertionImpl.java

@Override
public boolean isPresentlyValid() {
    Date now = new Date();

    if (getNotBefore() != null && now.before(getNotBefore())) {
        LOGGER.debug("SAML Assertion Time Bound Check Failed.");
        LOGGER.debug("\t Checked time of {} is before the NotBefore time of {}", now, getNotBefore());
        return false;
    }// www .ja v a2s .  co m

    if (getNotOnOrAfter() != null && (now.equals(getNotOnOrAfter()) || now.after(getNotOnOrAfter()))) {
        LOGGER.debug("SAML Assertion Time Bound Check Failed.");
        LOGGER.debug("\t Checked time of {} is equal to or after the NotOnOrAfter time of {}", now,
                getNotOnOrAfter());
        return false;
    }

    return true;
}

From source file:net.chaosserver.timelord.data.TimelordTask.java

/**
 * Gets the TaskDay object for the date to find.  If the create
 * flag is true, than a new object will be created if there is no
 * existing one./*  w ww.ja v a  2s  .  com*/
 *
 * @param dateToFind the date to retrieve the task date object for.
 * @param create should the object be created if one doesn't exist
 * @return the TaskDate for the day, or a null if create is false
 *         and no object currently exists
 */
public synchronized TimelordTaskDay getTaskDay(Date dateToFind, boolean create) {
    if (log.isDebugEnabled()) {
        log.debug("Searching [" + getTaskName() + "] for date of [" + dateToFind + "]");
    }

    TimelordTaskDay timelordTaskDay = null;

    Iterator<TimelordTaskDay> taskDayListIterator = getTaskDayList().iterator();

    while ((timelordTaskDay == null) && taskDayListIterator.hasNext()) {
        TimelordTaskDay tempTimelordTaskDay = (TimelordTaskDay) taskDayListIterator.next();

        if (log.isDebugEnabled()) {
            log.debug("Testing tempTimelordTaskDay.getDate [" + tempTimelordTaskDay.getDate()
                    + "] againt dateToFind of [" + dateToFind + "]");
        }

        if (dateToFind.equals(tempTimelordTaskDay.getDate())) {
            timelordTaskDay = tempTimelordTaskDay;
        } else if (dateToFind.after(tempTimelordTaskDay.getDate())) {
            // If the date to find is after the date we want, then we are
            // DONE.
            break;
        }
    }

    if ((timelordTaskDay == null) && create) {
        if (log.isDebugEnabled()) {
            log.debug("Creating new TimelordTaskDay for [" + dateToFind + "]");
        }

        timelordTaskDay = add(dateToFind);
    }

    return timelordTaskDay;
}

From source file:net.audumla.astronomy.algorithims.EllipticalObject.java

@Override
public TransitDetails getTransitDetails(Date date, Geolocation location, double altitude) {
    // to make sure that the dates for rise and set are for the correct day this code checks the resultant rise and set days.
    // as all times are calculated using UTC there is a chance that they may not be for the requested local day.
    // I have attempted to adjust the passed in time using the local time offset however this has not worked, so a
    // brute force method has been applied to recalculate using either the next or previous day.
    // this method has also run into problems when adjusting by +/- 24 hours. It appears that borderline cases may actually
    // cause the calculation to jump another whole day and therefore result in a calculation that is another full day in the
    // desired direction. Currently it appears that using +/- 23 hours will fix this as the borderline cases are as result
    // of the few seconds/minutes difference in rise times each day. This needs to be monitored however and more thorough testing applied.
    JulianTransitDetails details = calcTransitDetails(date, location, altitude);
    JulianTransitDetails detailsAdj = null;
    if (!DateUtils.isSameDay(date, details.getRiseTime())) {
        detailsAdj = calcTransitDetails(DateUtils.addHours(date, date.after(date) ? 23 : -23), location,
                altitude);/*from  w w w . ja  v  a  2  s . c o m*/
        details.setRise((detailsAdj.getJulianRise().julian() - details.getReferenceTime().julian()) * 24);
    }

    if (!DateUtils.isSameDay(date, details.getSetTime())) {
        detailsAdj = calcTransitDetails(DateUtils.addHours(date, date.after(date) ? 23 : -23), location,
                altitude);
        details.setSet((detailsAdj.getJulianSet().julian() - details.getReferenceTime().julian()) * 24);
    }

    assert DateUtils.isSameDay(details.getRiseTime(), details.getSetTime());
    return details;
}

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

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

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

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

            earliestProductionTime = productionTime;
        }
    }
    return earliestProductionTime;
}

From source file:org.phenotips.data.internal.MonarchPatientScorerTest.java

@Test
public void getSpecificitySearchesRemotely() throws Exception {
    Mockito.doReturn(this.features).when(this.patient).getFeatures();
    URI expectedURI = new URI("https://monarchinitiative.org/score");
    CapturingMatcher<HttpPost> reqCapture = new CapturingMatcher<>();
    when(this.client.execute(Matchers.argThat(reqCapture))).thenReturn(this.response);
    when(this.response.getEntity()).thenReturn(this.responseEntity);
    when(this.responseEntity.getContent())
            .thenReturn(IOUtils.toInputStream("{\"scaled_score\":2}", StandardCharsets.UTF_8));
    CapturingMatcher<PatientSpecificity> specCapture = new CapturingMatcher<>();
    Mockito.doNothing().when(this.cache).set(Matchers.eq("HP:1-HP:2"), Matchers.argThat(specCapture));
    Date d1 = new Date();
    this.mocker.getComponentUnderTest().getSpecificity(this.patient);
    Date d2 = new Date();
    PatientSpecificity spec = specCapture.getLastValue();
    Assert.assertEquals(expectedURI, reqCapture.getLastValue().getURI());
    String content = URLDecoder
            .decode(IOUtils.toString(reqCapture.getLastValue().getEntity().getContent(), "UTF-8"), "UTF-8");
    Assert.assertTrue(content.startsWith("annotation_profile="));
    JSONObject actualJson = new JSONObject(content.substring("annotation_profile=".length()));
    JSONObject expectedJson = new JSONObject(
            "{\"features\":[{\"id\":\"HP:1\"},{\"id\":\"HP:2\",\"isPresent\":false}]}");
    Assert.assertTrue(expectedJson.similar(actualJson));
    Assert.assertEquals("application/x-www-form-urlencoded; charset=UTF-8",
            reqCapture.getLastValue().getEntity().getContentType().getValue());
    Assert.assertEquals(2.0, spec.getScore(), 0.0);
    Assert.assertEquals("monarchinitiative.org", spec.getComputingMethod());
    Assert.assertFalse(d1.after(spec.getComputationDate()));
    Assert.assertFalse(d2.before(spec.getComputationDate()));
}

From source file:dk.netarkivet.harvester.datamodel.JobDAOTester.java

/** Check that start and end dates are created and stored correctly. */
@Test/* ww w  . j a va 2  s.  c o m*/
public void testSetDates() {
    //DomainDAO ddao = DomainDAO.getInstance();
    Date startDate = new Date();
    Job newJob1 = createDefaultJobInDB(2);
    newJob1.setStatus(JobStatus.SUBMITTED);
    jobDAO.update(newJob1);
    assertNull("Should have null start date at start, but was " + newJob1.getActualStart(),
            newJob1.getActualStart());
    assertNull("Should have null stop date at start, but was " + newJob1.getActualStop(),
            newJob1.getActualStop());
    newJob1.setStatus(JobStatus.STARTED);
    assertNotNull("Should have non-null start date after starting", newJob1.getActualStart());
    assertFalse("Should have updated start date after starting (>= before)",
            startDate.after(newJob1.getActualStart()));
    assertFalse("Should have updated start date after starting (<= now)",
            new Date().before(newJob1.getActualStart()));
    assertNull("Should have null stop date after starting, but was " + newJob1.getActualStop(),
            newJob1.getActualStop());
    jobDAO.update(newJob1);
    Job newJob2 = jobDAO.read(newJob1.getJobID());
    assertNotNull("Should have non-null start date after rereading", newJob2.getActualStart());
    assertEquals("Should have same start date after rereading", newJob1.getActualStart(),
            newJob2.getActualStart());
    assertNull("Should have null stop date after rereading, but was " + newJob2.getActualStop(),
            newJob2.getActualStop());
    try {
        // Make sure new time is different
        Thread.sleep(1);
    } catch (InterruptedException e) {
        // Ignored
    }
    Date stopDate = new Date();
    newJob2.setStatus(JobStatus.DONE);
    assertNotNull("Should have non-null start date after finishing", newJob2.getActualStart());
    assertEquals("Should have same start date after rereading", newJob1.getActualStart(),
            newJob2.getActualStart());
    assertNotNull("Should have non-null stop date after finishing", newJob2.getActualStop());
    assertFalse("Should have updated stop date after finishing (>= before)",
            stopDate.after(newJob2.getActualStop()));
    assertFalse("Should have updated stop date after finishing (<= now)",
            new Date().before(newJob2.getActualStop()));
    jobDAO.update(newJob2);
    Job newJob3 = jobDAO.read(newJob2.getJobID());
    assertNotNull("Should have non-null start date after rerereading", newJob3.getActualStart());
    assertEquals("Should have same start date after rereading", newJob2.getActualStart(),
            newJob3.getActualStart());
    assertNotNull("Should have non-null stop date after rerereading", newJob3.getActualStop());
    assertEquals("Should have same stop date after rereading", newJob2.getActualStop(),
            newJob3.getActualStop());
}

From source file:com.db4o.sync4o.SyncDb.java

private List findKeysBetween(final SyncClass syncClass, final char state, final Date start, final Date finish) {

    Query query = _shadowDb.query();
    query.constrain(SyncObjectInfo.class);
    query.constrain(new Evaluation() {

        public void evaluate(Candidate c) {

            boolean matches = false;
            SyncObjectInfo info = (SyncObjectInfo) c.getObject();
            if (syncClass.getConfig().equals(info.getClassInfo().getConfig()) && info.getSyncState() == state) {

                Date timestamp = info.getTimestamp();
                matches = ((start == null) || start.before(timestamp))
                        && ((finish == null) || finish.after(timestamp));

            }//from w  w w. ja va 2  s . co  m

            c.include(matches);

        }

    });

    return query.execute();

}

From source file:Forms.frm_Penghuni.java

public boolean validasitanggal() {

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date sekarang = new Date();
    String sekarang1 = dateFormat.format(sekarang);
    //        Date tanggal_sekarang = dateFormat.format(sekarang);
    String tgl_lahir = dateFormat.format(dcTanggalLahirPenghuni.getDate());
    //        Date tgl_lahir = dcTanggalLahirPenghuni.getDate();

    Date sek;/*from w  w  w  . j  av  a  2  s  .  c  om*/
    try {
        sek = dateFormat.parse(sekarang1);
        Date lahir = dateFormat.parse(tgl_lahir);

        if (lahir.equals(sek)) {
            JOptionPane.showMessageDialog(null,
                    "Tanggal Lahir Sama dengan Hari Ini.. \n Silahkan Isi Dengan Benar!");
            dcTanggalLahirPenghuni.requestFocus();
            return false;
        } else if (lahir.after(sek)) {
            JOptionPane.showMessageDialog(null,
                    "Apakah Penghuni berasal dari masa depan?.. \n Silahkan Isi Dengan Benar!");
            dcTanggalLahirPenghuni.requestFocus();
            return false;
        } else {
            return true;
        }
    } catch (ParseException ex) {
        Logger.getLogger(frm_Penghuni.class.getName()).log(Level.SEVERE, null, ex);
    }

    return false;

}