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:org.taverna.server.master.mocks.ExampleRun.java

@Override
public void setExpiry(Date d) {
    if (d.after(new Date()))
        this.expiry = d;
}

From source file:logdruid.data.MineResult.java

public File getFileForDate(Date date) {
    Iterator<Object[]> it = fileDates.iterator();
    while (it.hasNext()) {
        Object[] obj = it.next();
        if (logger.isDebugEnabled())
            logger.debug(//from   ww  w  .j a  va  2  s.  com
                    "1: " + (Date) obj[0] + "2: " + (Date) obj[1] + "3: " + ((FileRecord) obj[2]).getFile());
        if (date.after((Date) obj[0]) && date.before((Date) obj[1]))
            return (File) ((FileRecord) obj[2]).getFile();
    }
    return null;
}

From source file:com.javielinux.utils.Utils.java

static public void saveApiConfiguration(Context cnt) {
    boolean todo = false;
    long time = PreferenceUtils.getDateApiConfiguration(cnt);
    if (time < 0) {
        PreferenceUtils.setDateApiConfiguration(cnt, new Date().getTime());
        todo = true;// www.ja va  2s  .c o m
    } else {
        Date dateToday = new Date();
        Date dateRefresh = new Date(time);
        if (dateToday.after(dateRefresh)) {
            todo = true;
            Calendar calToday = Calendar.getInstance();
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd H:m");
            String tomorrow = Utils.getTomorrow(calToday.get(Calendar.YEAR), (calToday.get(Calendar.MONTH) + 1),
                    calToday.get(Calendar.DATE));
            try {
                Date nextDate = format.parse(tomorrow + " 10:00");
                PreferenceUtils.setDateApiConfiguration(cnt, nextDate.getTime());
            } catch (ParseException e) {
                e.printStackTrace();
            }

        }
    }

    if (todo) {

        Log.d(Utils.TAG, "Cargar configuracin");

        ConnectionManager.getInstance().open(cnt);

        try {
            TwitterAPIConfiguration api = ConnectionManager.getInstance().getUserForSearchesTwitter()
                    .getAPIConfiguration();
            PreferenceUtils.setShortURLLength(cnt, api.getShortURLLength());
            PreferenceUtils.setShortURLLengthHttps(cnt, api.getShortURLLengthHttps());
        } catch (TwitterException e1) {
            e1.printStackTrace();
        } catch (Exception e1) {
            e1.printStackTrace();
        }

    }
}

From source file:com.thinkbiganalytics.servicemonitor.model.DefaultServiceStatusResponse.java

private void updateServiceState() {
    List<ServiceComponent.STATE> states = new ArrayList<ServiceComponent.STATE>();
    boolean hasErrorAlerts = false;
    Date latestAlertTimestamp = null;
    Date earliestAlertTimestamp = null;
    if (components != null && !components.isEmpty()) {
        for (ServiceComponent component : this.getComponents()) {

            if (StringUtils.isBlank(component.getServiceName())) {
                component.setServiceName(serviceName);
            }// w w  w  . j  a  v  a  2 s  .  c  om

            states.add(component.getState());
            if (component.isContainsErrorAlerts()) {
                hasErrorAlerts = true;
            }
            if (!component.isHealthy()) {
                this.unhealthyComponents.add(component);
            } else {
                this.healthyComponents.add(component);
            }
            Date latest = component.getLatestAlertTimestamp();
            Date earliest = component.getEarliestAlertTimestamp();
            if (latestAlertTimestamp == null
                    || (latestAlertTimestamp != null && latest != null && latest.after(latestAlertTimestamp))) {
                latestAlertTimestamp = component.getLatestAlertTimestamp();
            }
            if (earliestAlertTimestamp == null || (earliestAlertTimestamp != null && earliest != null
                    && earliest.after(earliestAlertTimestamp))) {
                earliestAlertTimestamp = component.getEarliestAlertTimestamp();
            }
        }
    }
    if (latestAlertTimestamp == null) {
        latestAlertTimestamp = new Date();
    }
    if (earliestAlertTimestamp == null) {
        earliestAlertTimestamp = new Date();
    }
    this.latestAlertTimestamp = latestAlertTimestamp;
    this.earliestAlertTimestamp = earliestAlertTimestamp;
    if (states.contains(ServiceComponent.STATE.DOWN)) {
        this.state = STATE.DOWN;
    } else if ((states.contains(ServiceComponent.STATE.UP) && hasErrorAlerts)
            || states.contains(ServiceComponent.STATE.UNKNOWN)) {
        this.state = STATE.WARNING;
    } else {
        this.state = STATE.UP;
    }

}

From source file:com.linuxbox.enkive.message.search.RetentionPolicyEnforcingMessageSearchService.java

private Map<String, String> addRetentionPolicyToFields(Map<String, String> searchFields) {
    HashMap<String, String> retentionFields = messageRetentionPolicy.getRetentionPolicyCriteria();

    if (retentionFields.get(RETENTION_PERIOD) != null && !retentionFields.get(RETENTION_PERIOD).isEmpty()
            && Integer.parseInt(retentionFields.get(RETENTION_PERIOD)) > 0) {

        String retentionPeriodString = retentionFields.get(RETENTION_PERIOD);
        int retentionPeriod = Integer.parseInt(retentionPeriodString);
        Calendar retentionCal = Calendar.getInstance();
        retentionCal.add(Calendar.DATE, (-1 * retentionPeriod));
        Date retentionDate = retentionCal.getTime();

        if (searchFields.get(DATE_EARLIEST_PARAMETER) != null
                && !searchFields.get(DATE_EARLIEST_PARAMETER).isEmpty()) {
            try {
                Date searchDate = NUMERIC_SEARCH_FORMAT.parse(searchFields.get(DATE_EARLIEST_PARAMETER));
                if (retentionDate.after(searchDate)) {
                    searchFields.put(DATE_EARLIEST_PARAMETER, NUMERIC_SEARCH_FORMAT.format(retentionDate));
                }/*from  w ww  . ja  va 2s  .c  o m*/
            } catch (ParseException e) {
                searchFields.put(DATE_EARLIEST_PARAMETER, NUMERIC_SEARCH_FORMAT.format(retentionDate));
                if (LOGGER.isWarnEnabled())
                    LOGGER.warn("Could not parse earliest date submitted to search - "
                            + searchFields.get(DATE_EARLIEST_PARAMETER));
            }
        } else {
            searchFields.put(DATE_EARLIEST_PARAMETER, NUMERIC_SEARCH_FORMAT.format(retentionDate));
        }
    }

    return searchFields;
}

From source file:com.vmware.identity.openidconnect.server.SlidingWindowMap.java

private void cleanUp(Date now) {
    // the oldest items are at the head of the queue, as long as we see expired items we continue removing
    Iterator<Entry<K, Pair<V, Date>>> iterator = this.map.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<K, Pair<V, Date>> entry = iterator.next();
        Date insertionDate = entry.getValue().getRight();
        if (now.after(new Date(insertionDate.getTime() + this.widthMilliseconds))) {
            iterator.remove();//from   w  ww.  j  a  v  a2s .c o  m
        } else {
            break;
        }
    }
}

From source file:com.evolveum.midpoint.repo.sql.CleanupTest.java

License:asdf

@Test
public void testAuditCleanup() throws Exception {
    //GIVEN//from  ww  w .  j  a  v  a  2  s  .  c  o  m
    Calendar calendar = create_2013_07_12_12_00_Calendar();
    for (int i = 0; i < 3; i++) {
        long timestamp = calendar.getTimeInMillis();
        AuditEventRecord record = new AuditEventRecord();
        record.addDelta(createObjectDeltaOperation(i));
        record.setTimestamp(timestamp);
        LOGGER.info("Adding audit record with timestamp {}", new Object[] { new Date(timestamp) });

        auditService.audit(record, new SimpleTaskAdapter());
        calendar.add(Calendar.HOUR_OF_DAY, 1);
    }

    Session session = getFactory().openSession();
    try {
        session.beginTransaction();

        Query query = session.createQuery("select count(*) from " + RAuditEventRecord.class.getSimpleName());
        Long count = (Long) query.uniqueResult();

        AssertJUnit.assertEquals(3L, (long) count);
        session.getTransaction().commit();
    } finally {
        session.close();
    }

    //WHEN
    calendar = create_2013_07_12_12_00_Calendar();
    calendar.add(Calendar.HOUR_OF_DAY, 1);
    calendar.add(Calendar.MINUTE, 1);

    final long NOW = System.currentTimeMillis();
    CleanupPolicyType policy = createPolicy(calendar, NOW);

    OperationResult result = new OperationResult("Cleanup audit");
    auditService.cleanupAudit(policy, result);
    result.recomputeStatus();

    //THEN
    AssertJUnit.assertTrue(result.isSuccess());

    session = getFactory().openSession();
    try {
        session.beginTransaction();

        Query query = session.createQuery("from " + RAuditEventRecord.class.getSimpleName());
        List<RAuditEventRecord> records = query.list();

        AssertJUnit.assertEquals(1, records.size());
        RAuditEventRecord record = records.get(0);

        Date finished = new Date(record.getTimestamp().getTime());

        Date mark = new Date(NOW);
        Duration duration = policy.getMaxAge();
        duration.addTo(mark);

        AssertJUnit.assertTrue("finished: " + finished + ", mark: " + mark, finished.after(mark));

        session.getTransaction().commit();
    } finally {
        session.close();
    }
}

From source file:com.keedio.nifi.processors.azure.blob.PutAzureBlobObjectTest.java

@Test
public void testPutAzureBlobObjectProcessorOverride()
        throws IOException, ParseException, InitializationException, InterruptedException, InvalidKeyException,
        StorageException, URISyntaxException {
    CloudBlobWrapper blob = null;//from   w ww. ja v a  2 s . co m
    try {

        String connectionString = System.getProperty("storageConnectionString");
        String containerName = System.getProperty("containerName");

        Assume.assumeTrue(StringUtils.isNoneEmpty(connectionString, containerName));

        AzureBlobConnectionService connectionService = new AzureBlobConnectionServiceImpl();
        Map<String, String> controllerProperties = new HashMap<>();
        controllerProperties.put(AZURE_STORAGE_CONNECTION_STRING.getName(), connectionString);
        controllerProperties.put(AZURE_STORAGE_CONTAINER_NAME.getName(), containerName);

        testRunner.addControllerService("my-put-test-connection-service", connectionService,
                controllerProperties);

        testRunner.enableControllerService(connectionService);
        testRunner.assertValid(connectionService);
        testRunner.setProperty(AZURE_STORAGE_CONTROLLER_SERVICE, connectionService.getIdentifier());

        Date now = new Date();

        Thread.sleep(1100);

        testRunner.setProperty(AZURE_STORAGE_BEHAVIOUR_IF_BLOB_EXISTS, "overwrite");

        final String DYNAMIC_ATTRIB_KEY_1 = "runTimestamp";
        final String DYNAMIC_ATTRIB_VALUE_1 = String.valueOf(System.nanoTime());
        final String DYNAMIC_ATTRIB_KEY_2 = "testUploader";
        final String DYNAMIC_ATTRIB_VALUE_2 = "KEEDIO";

        PropertyDescriptor testAttrib1 = processor.getSupportedDynamicPropertyDescriptor(DYNAMIC_ATTRIB_KEY_1);
        testRunner.setProperty(testAttrib1, DYNAMIC_ATTRIB_VALUE_1);
        PropertyDescriptor testAttrib2 = processor.getSupportedDynamicPropertyDescriptor(DYNAMIC_ATTRIB_KEY_2);
        testRunner.setProperty(testAttrib2, DYNAMIC_ATTRIB_VALUE_2);

        final Map<String, String> attrs = new HashMap<>();
        attrs.put(CoreAttributes.FILENAME.key(), TEST_PUT_AZURE_BLOB_OBJECT_BLOCKBLOB_TMP);

        testRunner.enqueue(getResourcePath("/blockblob.tmp"), attrs);
        testRunner.assertValid();

        testRunner.run(1);
        testRunner.assertAllFlowFilesTransferred(REL_SUCCESS, 1);

        MockFlowFile mockFlowFile = testRunner.getFlowFilesForRelationship(REL_SUCCESS).get(0);
        Map<String, String> attributes = mockFlowFile.getAttributes();
        assertTrue(attributes.size() >= 3);

        assertEquals(TEST_PUT_AZURE_BLOB_OBJECT_BLOCKBLOB_TMP, attributes.get("metadata.blobName"));
        assertEquals("blobbasics3d8a33d05e7940dabbb92476fc4fb345", attributes.get("metadata.containerName"));
        assertNotNull(attributes.get("property.lastModified"));

        Date lastModified = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT
                .parse(attributes.get("property.lastModified"));

        assertTrue(lastModified.after(now) || lastModified.equals(now));

        assertTrue(Long.parseLong(attributes.get("property.length")) >= 0);
        assertFalse(attributes.containsKey("property.contentDisposition"));
        assertFalse(attributes.containsKey("property.copyState"));

        File localTestFile = new File("src/test/resources/blockblob.tmp");
        mockFlowFile.assertContentEquals(localTestFile);

        blob = new CloudBlobWrapper(TEST_PUT_AZURE_BLOB_OBJECT_BLOCKBLOB_TMP,
                connectionService.getCloudBlobContainerReference());

        try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
            blob.download(os);
            assertEquals(localTestFile.length(), os.toByteArray().length);
        }
    } finally {
        if (blob != null)
            blob.deleteIfExists();
    }
}

From source file:de.ncoder.studipsync.Syncer.java

public boolean areFilesInSync(List<Download> downloads, List<Path> localFiles) throws IOException {
    if (!checkLevel.includes(CheckLevel.Files)) {
        return true;
    }/*from w  ww  . j a  v  a 2 s  . com*/
    for (Download download : downloads) {
        //Find matching candidates
        List<Path> localCandidates = new LinkedList<>();
        for (Path local : localFiles) {
            // Check candidate name
            if (local.getName(local.getNameCount() - 1).toString().equals(download.getFileName())) {
                if (!localCandidates.isEmpty()) {
                    //Already found a candidate
                    log.debug(marker,
                            "Local files " + localCandidates + " and " + local + " match " + download + "!");
                }
                localCandidates.add(local);

                //Check LastModifiedTime
                if (!checkLevel.includes(CheckLevel.ModTime)) {
                    continue;
                }
                Date localLastMod = new Date(Files.getLastModifiedTime(local).toMillis());
                if (!localLastMod.after(download.getLastModified())) {
                    //Candidate *potentially* outdated
                    log.warn(marker, "Local file " + local + "(" + localLastMod + ") older than online Version "
                            + download + "(" + download.getLastModified() + ")!");
                    return false;
                }
            }
        }

        //Require at least one candidate
        if (localCandidates.isEmpty()) {
            //No candidates found
            log.warn(marker, "No local file matching " + download + " (~" + download.getFileName() + ")!");
            return false;
        }
    }
    return true;
}

From source file:com.iorga.webappwatcher.analyzer.model.session.DurationPerPrincipalStats.java

private boolean isDateInTimeSlice(final Date date, final TimeSlice currentTimeSlice) {
    return date.after(currentTimeSlice.startDate) && date.before(currentTimeSlice.endDate);
}