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:org.apache.cxf.fediz.service.idp.beans.WfreshParser.java

public boolean authenticationRequired(String wfresh, String whr, RequestContext context) throws Exception {

    SecurityToken idpToken = (SecurityToken) WebUtils.getAttributeFromExternalContext(context, whr);
    if (idpToken.isExpired()) {
        LOG.info("[IDP_TOKEN=" + idpToken.getId() + "] is expired.");
        return true;
    }/*from ww  w . j a v  a 2  s.  co  m*/

    if (wfresh == null || wfresh.trim().isEmpty()) {
        return false;
    }

    long ttl;
    try {
        ttl = Long.parseLong(wfresh.trim());
    } catch (Exception e) {
        LOG.info("wfresh value '" + wfresh + "' is invalid.");
        return false;
    }
    if (ttl == 0) {
        return true;
    } else if (ttl > 0) {

        Date createdDate = idpToken.getCreated();
        if (createdDate != null) {
            Date expiryDate = new Date();
            expiryDate.setTime(createdDate.getTime() + (ttl * 60L * 1000L));
            if (expiryDate.before(new Date())) {
                LOG.info("[IDP_TOKEN=" + idpToken.getId()
                        + "] is valid but relying party requested new authentication caused by wfresh=" + wfresh
                        + " outdated.");
                return true;
            }
        } else {
            LOG.info("token creation date not set. Unable to check wfresh is outdated.");
        }
    } else {
        LOG.info("ttl value '" + ttl + "' is negative.");
    }
    return false;
}

From source file:com.boubei.tss.modules.license.LicenseManager.java

public void loadLicenses() {
    if (!EasyUtils.isNullOrEmpty(licenses))
        return;/*from   www  .  jav  a  2 s .co  m*/

    licenses = new ArrayList<License>();
    String files[] = new File(LicenseFactory.LICENSE_DIR).list();
    for (int i = 0; i < files.length; i++) {
        String filename = files[i];
        File file = new File(LicenseFactory.LICENSE_DIR, filename);
        if (file.isDirectory() || !filename.endsWith(".license")) {
            continue;
        }

        try {
            License license = License.fromConfigFile(filename);

            Date expiresDate = license.expiry;
            if (expiresDate != null && expiresDate.before(new Date())) {
                log.error("license \"" + file.getName() + "\" ?.");
                continue;
            }
            if (!validate(license)) {
                log.error("license \"" + file.getName() + "\" ??.");
                continue;
            }

            licenses.add(license);
        } catch (Exception e) {
        }
    }
}

From source file:com.softwarecorporativo.monitoriaifpe.modelo.atividade.validation.ValidadorAtividade.java

@Override
public boolean isValid(Atividade atividade, ConstraintValidatorContext cvc) {
    Date dataInicio = atividade.getDataInicio();
    Date dataFim = atividade.getDataFim();
    if (dataInicio != null && dataFim != null) {
        return (DateUtils.isSameDay(dataInicio, dataInicio) && dataInicio.before(dataFim));
    }/*from  w  w  w.j a  v  a 2  s . c o  m*/
    return Boolean.FALSE;
}

From source file:com.biosis.biosislite.interpretes.InterpreteTardanzaMensual.java

private double tardanzaMin(Date evento, Date tolerancia) {
    System.out.println("HORA EVENTO: " + evento + " TOLERANCIA: " + tolerancia);
    if (tolerancia.before(evento)) {
        double tardanza = (FechaUtil.soloHora(evento).getTime() - FechaUtil.soloHora(tolerancia).getTime())
                / (60 * 1000);//from w w  w  .  j  a  v a 2s . c  om
        if (tardanza >= 1) {
            return tardanza;
        } else {
            return 0.0;
        }

    } else {
        return 0.0;
    }
}

From source file:architectgroup.udr.webserver.controller.LicenseController.java

@RequestMapping(value = "/license/detail")
public ModelAndView detail() {
    ModelAndView modelAndView = new ModelAndView();
    LicenseAccess licenseAccess = new LicenseAccess();
    String data = licenseAccess.getData(getClass().getResourceAsStream("/license/udr-license"));
    KeyStatus status = KeyStatus.KEY_INVALID;

    if (session.getLic() == null) {
        try {/*from   w ww.  java 2 s. co  m*/
            status = licenseAccess.verify(getClass().getResourceAsStream("/license/udr-license"));
        } catch (Exception err) {
            System.out.println("Can not verify the license.");
        }

        // Init the license //
        LicenseObject lic = new LicenseObject(status, "--", "--", new Date(), "--");
        session.setLic(lic);

        if (status == KeyStatus.KEY_VALID) {
            String[] p = data.split("#");
            String date = p[3];
            String version = p[2];
            String host = p[1];
            Date licDate = new Date();
            try {
                licDate = dateFormat.parse(date);
            } catch (ParseException e) {
                e.printStackTrace();
            }

            if (!p[0].equalsIgnoreCase("TRIAL") || !p[1].equalsIgnoreCase("TRIAL")) {
                if (host.equalsIgnoreCase(CommonFunction.getHostAddress())) {
                    Date current = new Date();
                    if (current.before(licDate)) {
                        String[] ver = version.split(".");
                        String currentVersion = messageSource.getMessage("version", null, Locale.ENGLISH);
                        String[] curver = currentVersion.split(".");
                        if (ver[0].equalsIgnoreCase(curver[0]) && ver[1].equalsIgnoreCase(curver[1])) {
                            lic = new LicenseObject(status, p[0], host, licDate, version);
                            session.setLic(lic);
                        } else {
                            lic = new LicenseObject(KeyStatus.KEY_INVALID, p[0], host, licDate,
                                    "Incorrect version");
                            session.setLic(lic);
                        }
                    } else {
                        lic = new LicenseObject(KeyStatus.KEY_EXPIRED, p[0], host, licDate, version);
                        session.setLic(lic);
                    }
                } else {
                    lic = new LicenseObject(KeyStatus.KEY_INVALID, "--", "--", new Date(), "--");
                    session.setLic(lic);
                }
            } else {
                lic = new LicenseObject(KeyStatus.KEY_VALID, "TRIAL", "TRIAL", licDate, p[2]);
                session.setLic(lic);
            }
        }
    }

    modelAndView.addObject("key", session.getLic().getStatus());
    modelAndView.addObject("name", session.getLic().getName());
    modelAndView.addObject("host", session.getLic().getHostId());
    modelAndView.addObject("version", session.getLic().getVersion());
    modelAndView.addObject("date", dateFormat.format(session.getLic().getExpiration()));
    modelAndView.addObject("currenthost", CommonFunction.getHostAddress());

    return modelAndView;
}

From source file:net.audumla.climate.bom.BOMSimpleClimateForcastObserver.java

synchronized public ClimateData getClimateData(Date date) {
    if (date.before(Time.getToday())) {
        throw new UnsupportedOperationException("JulianDate requested is in the past and cannot be forecast");
    }// w  w w . jav a2  s . co m
    Date newDate;
    try {
        newDate = forcastDateFormat.parse(forcastDateFormat.format(date));
        ClimateData forcast = forcastData.get(newDate);
        if (forcast == null) {
            loadLatestForcast();
            forcast = forcastData.get(newDate);
        }
        if (forcast == null) {
            throw new UnsupportedOperationException("JulianDate is not in forecast data");
        } else {
            return forcast;
        }
    } catch (ParseException e) {
        throw new UnsupportedOperationException("Error getting BOM forcast", e);
    }
}

From source file:com.toptal.controller.EntryController.java

/**
 * Filtered entries of the actual user.// w  w  w .j  av  a 2  s . c om
 * @param start Start date.
 * @param end End date.
 * @return Entries from the period start to end.
 */
@RequestMapping(value = "/{start}/{end}", method = RequestMethod.GET)
public final Iterable<Entry> filter(@PathVariable @DateTimeFormat(iso = ISO.DATE) final Date start,
        @PathVariable @DateTimeFormat(iso = ISO.DATE) final Date end) {
    if (end.before(start)) {
        throw new IllegalArgumentException("Start date must be before end");
    }
    final List<Entry> result = new LinkedList<Entry>();
    List<Entry> entries = SecurityUtils.actualUser().getEntries();
    if (entries == null) {
        entries = Collections.emptyList();
    }
    for (final Entry entry : entries) {
        if (entry.getDate().after(start) && entry.getDate().before(end)) {
            result.add(entry);
        }
    }
    return result;
}

From source file:fi.vm.sade.eperusteet.ylops.resource.dokumentti.DokumenttiController.java

private boolean isTimePass(DokumenttiDto dokumenttiDto) {
    Date date = dokumenttiDto.getAloitusaika();
    if (date == null) {
        return true;
    }/*ww w  .ja  va2  s  . c  om*/

    Date newDate = DateUtils.addMinutes(date, MAX_TIME_IN_MINUTES);
    return newDate.before(new Date());
}

From source file:fr.pasteque.client.models.Discount.java

public boolean isValid() {
    if (endDate.before(startDate))
        Log.w(LOG_TAG, "Corrupted Discount, endDate is anterior to startDate");
    Date now = Calendar.getInstance().getTime();
    return now.after(startDate) && now.before(endDate);
}

From source file:com.jevontech.wabl.security.TokenUtils.java

private Boolean isTokenExpired(String token) {
    final Date expiration = this.getExpirationDateFromToken(token);
    return expiration.before(this.generateCurrentDate());
}