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:eionet.transfer.dao.UploadsServiceSwift.java

@Override
public Upload getById(String fileId) throws IOException {
    if (config == null) {
        login();//from  w w w  .  j a va 2 s. c  om
    }
    Upload uploadRec = new Upload();
    StoredObject swiftObject = null;
    try {
        swiftObject = container.getObject(fileId);
    } catch (Exception e) {
        throw new FileNotFoundException(fileId);
    }
    Map<String, Object> metadata = swiftObject.getMetadata();
    uploadRec.setExpires(swiftObject.getDeleteAtAsDate());
    uploadRec.setFilename((String) metadata.get("filename"));
    uploadRec.setContentType((String) metadata.get("content-type"));
    uploadRec.setSize(swiftObject.getContentLength());
    Date today = new Date(System.currentTimeMillis());
    if (uploadRec.getExpires() != null) {
        if (today.after(uploadRec.getExpires())) {
            throw new FileNotFoundException(fileId);
        }
    }
    uploadRec.setContentStream(swiftObject.downloadObjectAsInputStream());
    return uploadRec;
}

From source file:com.esri.geoevent.solutions.processor.updateOnly.UpdateOnlyProcessor.java

@Override
public GeoEvent process(GeoEvent geoEvent) throws Exception {
    String trackID = geoEvent.getTrackId();
    Date startTime = geoEvent.getStartTime();
    if (trackCache.containsKey(trackID)) {
        Date lastTime = trackCache.get(trackID);
        // Filter out any tracks that haven't been updated since last time
        if (!startTime.after(lastTime)) {
            LOG.trace("UpdateOnlyProcessor ignoring track as nothing new since last time: " + trackID + " : "
                    + startTime.toString());
            return null;
        }// www  .  ja  v  a2  s  . co m
        LOG.trace("UpdateOnlyProcessor is handling new data for track " + trackID + " : " + startTime.toString()
                + " is more recent than " + lastTime.toString());
    } else {
        LOG.trace("UpdateOnlyProcessor is handling a new track: " + trackID + " : " + startTime.toString());
    }
    // If we've reached here, then either there's an update to a track in the cache, or there's a new track, so record it in the cache
    trackCache.put(trackID, startTime);
    //... and allow the geoEvent through
    return geoEvent;
}

From source file:net.yacy.cora.protocol.ResponseHeader.java

/**
 * get http field Last-Modified or now (if header field is missing)
 * @return valid date (always != null)/*from w w w .  ja v  a  2s  .c o  m*/
 */
public Date lastModified() {
    if (this.date_cache_LastModified != null)
        return this.date_cache_LastModified;
    Date d = headerDate(HeaderFramework.LAST_MODIFIED);
    final Date now = new Date();
    this.date_cache_LastModified = (d == null) ? date() : d.after(now) ? now : d;
    return this.date_cache_LastModified;
}

From source file:de.incoherent.suseconferenceclient.tasks.CheckForUpdatesTask.java

@Override
protected Long doInBackground(Void... params) {
    String kUrl = "https://conference.opensuse.org/osem/api/v1/conferences/gRNyOIsTbvCfJY5ENYovBA";
    if (kUrl.length() <= 0)
        return 0l;

    String updatesUrl = mConference.getUrl() + "/updates.json";
    int lastUpdateRevision = mDb.getLastUpdateValue(mConference.getSqlId());
    int revisionLevel = lastUpdateRevision;

    try {// w w w .  j  ava 2s .  co m
        JSONObject updateReply = HTTPWrapper.get(updatesUrl);
        if (updateReply == null)
            return 0l;
        int newLevel = updateReply.getInt("revision");
        if (newLevel > revisionLevel) {
            long id = mConference.getSqlId();
            // Cache favorites and alerts
            List<String> favoriteGuids = mDb.getFavoriteGuids(id);
            List<Event> alerts = mDb.getAlertEvents(id);
            List<String> alertGuids = new ArrayList<String>();
            // Now cancel all of the outstanding alerts, in case
            // a talk has been moved
            AlarmManager manager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
            for (Event e : alerts) {
                alertGuids.add("\"" + e.getGuid() + "\"");
                Log.d("SUSEConferences", "Removing an alert for " + e.getTitle());

                Intent intent = new Intent(mContext, AlarmReceiver.class);
                intent.putExtras(ScheduleDetailsActivity.generateAlarmIntentBundle(mContext, e));
                PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
                        intent.getStringExtra("intentId").hashCode(), intent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                manager.cancel(pendingIntent);
                pendingIntent.cancel();
            }

            // Now clear the DB
            mDb.clearDatabase(id);
            // Download schedule
            ConferenceCacher cacher = new ConferenceCacher(new ConferenceCacherProgressListener() {
                @Override
                public void progress(String progress) {
                    publishProgress(progress);
                }
            });

            long val = cacher.cacheConference(mConference, mDb);
            mErrorMessage = cacher.getLastError();
            if (val == -1) {
                mDb.setConferenceAsCached(id, 0);
            } else {
                mDb.setLastUpdateValue(id, newLevel);
                mDb.toggleEventsInMySchedule(favoriteGuids);
                mDb.toggleEventAlerts(alertGuids);
                alerts = mDb.getAlertEvents(id);
                // ... And re-create the alerts, if they are in the future
                Date currentDate = new Date();
                for (Event e : alerts) {
                    if (currentDate.after(e.getDate()))
                        continue;
                    Log.d("SUSEConferences", "Adding an alert for " + e.getTitle());
                    alertGuids.add("\"" + e.getGuid() + "\"");
                    Intent intent = new Intent(mContext, AlarmReceiver.class);
                    intent.putExtras(ScheduleDetailsActivity.generateAlarmIntentBundle(mContext, e));
                    PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext,
                            intent.getStringExtra("intentId").hashCode(), intent,
                            PendingIntent.FLAG_UPDATE_CURRENT);
                    manager.set(AlarmManager.RTC_WAKEUP, e.getDate().getTime() - 300000, pendingIntent);
                }

            }
            return val;
        } else {
            return 0l;
        }
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SocketException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:org.apigw.authserver.svc.impl.ResidentServicesImpl.java

@Override
public boolean validateLegalGuardian(String legalGuardianResidentIdentificationNumber,
        String childResidentIdentificationNumber) throws IllegalArgumentException {
    log.debug("validateLegalGuardian");
    if (!RESIDENT_ID_PATTERN.matcher(legalGuardianResidentIdentificationNumber).matches()) {
        log.debug("legalGuardianResidentIdentificationNumber doesn't match pattern {}",
                RESIDENT_ID_PATTERN_REGEX);
        throw new IllegalArgumentException(
                "legalGuardianResidentIdentificationNumber doesn't match pattern " + RESIDENT_ID_PATTERN_REGEX);
    }/* w  w w  .  java 2s.c  om*/

    if (!RESIDENT_ID_PATTERN.matcher(childResidentIdentificationNumber).matches()) {
        log.debug("childResidentIdentificationNumber doesn't match pattern {}", RESIDENT_ID_PATTERN_REGEX);
        throw new IllegalArgumentException(
                "childResidentIdentificationNumber doesn't match pattern " + RESIDENT_ID_PATTERN_REGEX);
    }

    if (isOverAgeLimit(childResidentIdentificationNumber)) {
        log.debug("childResidentIdentificationNumber doesn't pass the ageLimit of {}", legalGuradianAgeLimit);
        return false;
    }

    LookupResidentForFullProfileType params = new LookupResidentForFullProfileType();
    params.getPersonId().add(legalGuardianResidentIdentificationNumber);
    //      LookUpSpecificationType spec = new LookUpSpecificationType();
    //      params.setLookUpSpecification(spec);
    LookupResidentForFullProfileResponseType response = lookupResidentForFullProfileClient
            .lookupResidentForFullProfile(lookupResidentForFullProfileLogicalAddress, params);
    if (response.getResident() == null || response.getResident().size() == 0) {
        log.warn(
                "A person with residentIdentificationNumber: {} wasn't found in the LookupResidentForFullProfile service.");
        return false;
    }
    boolean legalGuardianIsValid = false;
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
    Date now = new Date();
    for (ResidentType resident : response.getResident()) {
        if (resident.getPersonpost() != null && resident.getPersonpost().getRelationer() != null) {
            for (Relation relation : resident.getPersonpost().getRelationer().getRelation()) {
                if (relation.getRelationstyp() == RelationstypTYPE.V) {
                    log.debug("Found relation type V");
                    try {
                        if (relation.getRelationFromdatum() != null) {
                            log.debug("Found relation from date {}", relation.getRelationFromdatum());
                            Date from = df.parse(relation.getRelationFromdatum());
                            if (from.after(now)) {
                                log.debug("This relation has not reached the from date, continuing...");
                                continue;
                            }
                        }
                        if (relation.getRelationTomdatum() != null) {
                            log.debug("Found relation tom date {}", relation.getRelationTomdatum());
                            Date until = df.parse(relation.getRelationTomdatum());
                            if (until.before(now)) {
                                log.debug("This relation has passed the until date, continuing...");
                                continue;
                            }
                        }
                    } catch (ParseException e) {
                        log.error(
                                "ParseException while parsing from {} or until {} date, skipping this relation and continues...",
                                relation.getRelationFromdatum(), relation.getRelationTomdatum());
                        continue;
                    }
                    if (relation.getAvregistrering() != null) {
                        log.debug("This relation has been unregistered, continuing...");
                        continue;
                    }
                    if (relation.getStatus() == RelationStatusTYPE.AS
                            || relation.getStatus() == RelationStatusTYPE.AV
                            || relation.getStatus() == RelationStatusTYPE.IV
                            || relation.getStatus() == RelationStatusTYPE.AN) {
                        log.debug("This relation has status {}, continuing...", relation.getStatus());
                    }
                    if (relation.getRelationId() != null
                            && !StringUtils.isBlank(relation.getRelationId().getPersonNr())
                            && childResidentIdentificationNumber
                                    .equals(relation.getRelationId().getPersonNr())) {
                        log.debug("Found matching relation with relation type V");
                        legalGuardianIsValid = true;
                        break;
                    }
                    log.debug("This V relation didn't match");
                } else {
                    log.debug("Found non V relation type: {}, continuing", relation.getRelationstyp());
                    continue;
                }
            }
        }
        if (legalGuardianIsValid) {
            break;
        }
    }
    log.debug("validateLegalGuardian(legalGuardianResidentIdentificationNumber:NOT_LOGGED, "
            + "childResidentIdentificationNumber:NOT_LOGGED) returns: {}", legalGuardianIsValid);
    return legalGuardianIsValid;
}

From source file:com.cemeterylistingsweb.services.impl.ViewListingBySubscriberServiceImpl.java

@Override
public List<PublishedDeceasedListing> findListingBySubscriber(Long subID) {
    List<PublishedDeceasedListing> publists = publishRepo.findAll();
    //find listing by dob
    Subscriber sub = SubscrRepo.findOne(subID);

    List<PublishedDeceasedListing> list = new ArrayList();
    for (PublishedDeceasedListing pubListing : publists) {

        SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
        Date parsed = null;//  w w w.  ja v a 2  s  . co m
        try {
            parsed = format.parse(pubListing.getDateOfDeath());
        } catch (ParseException ex) {
            Logger.getLogger(ViewListingBySubscriberServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        java.sql.Date dod = new java.sql.Date(parsed.getTime());

        //Date dod = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH).parse(pubListing.getDateOfDeath());
        System.out.println(dod);

        if (dod.after(sub.getSubscriptionDate()) && dod.before(sub.getValidUntil()))
            System.out.println(dod);
        System.out.println("added" + "");
        list.add(pubListing);
    }

    return list;
}

From source file:io.github.benas.jpopulator.randomizers.DateRangeRandomizer.java

/**
 * Public constructor./*w w w . j  a va2s.  c  om*/
 * @param minDate the minimum date.
 * @param maxDate the maximum date.
 */
public DateRangeRandomizer(final Date minDate, final Date maxDate) {
    if (minDate == null) {
        throw new IllegalArgumentException("minDate must not be null");
    }
    if (maxDate == null) {
        throw new IllegalArgumentException("maxDate must not be null");
    }
    if (minDate.after(maxDate)) {
        throw new IllegalArgumentException("minDate must be before maxDate");
    }
    this.minDate = minDate;
    this.maxDate = maxDate;
}

From source file:org.openmrs.module.registration.web.controller.ajax.RegistrationAjaxController.java

/**
 * Check whether a day is later than today
 * //from   w  ww  .  j av  a 2s  . co  m
 * @param date
 * @return
 */
private boolean isLaterToday(Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(new Date());
    c.set(Calendar.HOUR, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    return date.after(c.getTime());
}

From source file:edu.stanford.muse.email.Filter.java

public boolean matchesDate(DatedDocument dd) {
    if (startDate != null && endDate != null) {
        Date d = dd.getDate();
        if (d == null)
            return false;
        if (d.before(startDate) || d.after(endDate))
            return false;
    }//from w  w w  .ja  v  a  2s  .  c o  m
    return true;
}

From source file:com.jiwhiz.domain.account.UserAccountRepositoryIT.java

@Test
public void testAuditing() {
    // create account
    UserAccount account = new UserAccount();
    account.getRoles().add(UserRoleType.ROLE_ADMIN);
    account.getRoles().add(UserRoleType.ROLE_AUTHOR);
    account.setDisplayName("John");
    account = accountRepository.save(account);
    String id = account.getId();//w  w w.jav  a2s .  c o m
    assertTrue(accountRepository.exists(id));

    // read
    UserAccount accountInDb = accountRepository.findOne(id);
    assertEquals(JiwhizBlogRepositoryTestApplication.TEST_AUDITOR, accountInDb.getCreatedBy());
    assertNotNull(accountInDb.getCreatedTime());
    assertEquals(JiwhizBlogRepositoryTestApplication.TEST_AUDITOR, accountInDb.getLastModifiedBy());
    assertNotNull(accountInDb.getLastModifiedTime());

    // update
    Date updatedTimeBefore = accountInDb.getLastModifiedTime();
    String newWebSite = "www.hello.com";
    account.setWebSite(newWebSite);
    accountRepository.save(account);
    accountInDb = accountRepository.findOne(id);
    assertFalse(updatedTimeBefore.after(accountInDb.getLastModifiedTime()));
}