Example usage for org.apache.commons.lang3.time DateUtils MILLIS_PER_SECOND

List of usage examples for org.apache.commons.lang3.time DateUtils MILLIS_PER_SECOND

Introduction

In this page you can find the example usage for org.apache.commons.lang3.time DateUtils MILLIS_PER_SECOND.

Prototype

long MILLIS_PER_SECOND

To view the source code for org.apache.commons.lang3.time DateUtils MILLIS_PER_SECOND.

Click Source Link

Document

Number of milliseconds in a standard second.

Usage

From source file:ca.uhn.fhir.jpa.dao.DaoConfig.java

public void setSubscriptionPurgeInactiveAfterSeconds(int theSeconds) {
    setSubscriptionPurgeInactiveAfterMillis(theSeconds * DateUtils.MILLIS_PER_SECOND);
}

From source file:org.eclipse.winery.repository.backend.BackendUtils.java

/**
 * @return true if given fileDate is newer then the modified date (or
 *         modified is null)// www  .ja  va2s .  co  m
 */
public static boolean isFileNewerThanModifiedDate(long millis, String modified) {
    if (modified == null) {
        return true;
    }

    Date modifiedDate = null;

    assert (Locale.getDefault() == Locale.ENGLISH);
    try {
        modifiedDate = DateUtils.parseDate(modified, org.apache.http.impl.cookie.DateUtils.DEFAULT_PATTERNS);
    } catch (ParseException e) {
        BackendUtils.logger.error(e.getMessage(), e);
    }

    if (modifiedDate != null) {
        // modifiedDate does not carry milliseconds, but fileDate does
        // therefore we have to do a range-based comparison
        if ((millis - modifiedDate.getTime()) < DateUtils.MILLIS_PER_SECOND) {
            return false;
        }
    }

    return true;
}

From source file:org.tightblog.rendering.cache.LazyExpiringCache.java

public void setTimeoutSec(int timeoutSec) {
    this.timeoutInMS = timeoutSec * DateUtils.MILLIS_PER_SECOND;
}

From source file:org.tightblog.service.indexer.IndexWeblogTask.java

public void doRun() {
    if (weblog == null && deleteOnly) {
        log.error("Weblog must be provided for delete task, skipping indexing");
        return;/*w  ww. jav  a 2s.  co m*/
    }

    Instant start = Instant.now();

    if (weblog == null) {
        log.info("Starting reindex of all weblogs...");
    }

    try (IndexWriter writer = beginWriting()) {
        if (writer != null) {

            // Delete all entries from given weblog(s)
            if (weblog != null) {
                Term tWebsite = getTerm(FieldConstants.WEBLOG_HANDLE, weblog.getHandle());

                if (tWebsite != null) {
                    writer.deleteDocuments(tWebsite);
                }
            } else {
                Term all = getTerm(FieldConstants.CONSTANT, FieldConstants.CONSTANT_V);
                writer.deleteDocuments(all);
            }

            if (!deleteOnly) {
                // Add entries from weblog(s)
                WeblogEntrySearchCriteria wesc = new WeblogEntrySearchCriteria();
                wesc.setWeblog(weblog);
                wesc.setStatus(PubStatus.PUBLISHED);
                List<WeblogEntry> entries = weblogEntryManager.getWeblogEntries(wesc);

                log.debug("Entries to index: {}", entries.size());

                for (WeblogEntry entry : entries) {
                    writer.addDocument(getDocument(entry));
                    log.debug("Indexed entry {0}: {1}", entry.getPubTime(), entry.getAnchor());
                }
            }
        }
    } catch (Exception e) {
        log.error("ERROR adding/deleting doc to index", e);
    }

    Instant end = Instant.now();
    double length = (end.toEpochMilli() - start.toEpochMilli()) / (double) DateUtils.MILLIS_PER_SECOND;

    if (weblog == null) {
        log.info("Indexed all weblogs in {} secs", length);
    } else {
        log.info("Indexed weblog '{}' in {} secs", weblog.getHandle(), length);
    }
}

From source file:org.tightblog.service.LuceneIndexerIT.java

@Test
public void testSearch() throws Exception {
    WeblogEntry wd1 = new WeblogEntry();
    wd1.setTitle("The Tholian Web");
    wd1.setText("When the Enterprise attempts to ascertain the fate of the  "
            + "U.S.S. Defiant which vanished 3 weeks ago, the warp engines  "
            + "begin to lose power, and Spock reports strange sensor readings.");
    wd1.setAnchor("dummy1");
    wd1.setCreator(testUser);/*from  w w  w.  j av  a  2 s  .  c  o m*/
    wd1.setStatus(PubStatus.PUBLISHED);
    wd1.setUpdateTime(Instant.now());
    wd1.setPubTime(Instant.now());
    wd1.setWeblog(testWeblog);

    WeblogCategory cat = weblogCategoryRepository.findByWeblogAndName(testWeblog, "General");
    wd1.setCategory(cat);

    weblogEntryManager.saveWeblogEntry(wd1);
    wd1 = weblogEntryRepository.findByIdOrNull(wd1.getId());

    luceneIndexer
            .executeIndexOperationNow(new IndexEntryTask(weblogEntryRepository, luceneIndexer, wd1, false));

    WeblogEntry wd2 = new WeblogEntry();
    wd2.setTitle("A Piece of the Action");
    wd2.setText("The crew of the Enterprise attempts to make contact with "
            + "the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
            + "in communication with Boss Oxmyx.");
    wd2.setAnchor("dummy2");
    wd2.setStatus(PubStatus.PUBLISHED);
    wd2.setCreator(testUser);
    wd2.setUpdateTime(Instant.now());
    wd2.setPubTime(Instant.now());
    wd2.setWeblog(testWeblog);

    cat = weblogCategoryRepository.findByWeblogAndName(testWeblog, "General");
    wd2.setCategory(cat);

    weblogEntryManager.saveWeblogEntry(wd2);
    wd2 = weblogEntryRepository.findByIdOrNull(wd2.getId());

    luceneIndexer
            .executeIndexOperationNow(new IndexEntryTask(weblogEntryRepository, luceneIndexer, wd2, false));

    Thread.sleep(DateUtils.MILLIS_PER_SECOND);

    SearchTask search = new SearchTask(luceneIndexer);
    search.setTerm("Enterprise");
    luceneIndexer.executeIndexOperationNow(search);
    assertEquals(2, search.getResultsCount());

    SearchTask search2 = new SearchTask(luceneIndexer);
    search2.setTerm("Tholian");
    luceneIndexer.executeIndexOperationNow(search2);
    assertEquals(1, search2.getResultsCount());

    // Clean up
    IndexEntryTask t1 = new IndexEntryTask(weblogEntryRepository, luceneIndexer, wd1, true);
    luceneIndexer.executeIndexOperationNow(t1);
    IndexEntryTask t2 = new IndexEntryTask(weblogEntryRepository, luceneIndexer, wd2, true);
    luceneIndexer.executeIndexOperationNow(t2);

    SearchTask search3 = new SearchTask(luceneIndexer);
    search3.setTerm("Enterprise");
    luceneIndexer.executeIndexOperationNow(search3);
    assertEquals(0, search3.getResultsCount());
}