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:be.fedict.trust.crl.CrlTrustLinker.java

/**
 * Checks the integrity of the given X509 CRL.
 * /*  w  w w  . j a  v  a  2 s .co  m*/
 * @param x509crl
 *            the X509 CRL to verify the integrity.
 * @param issuerCertificate
 *            the assumed issuer of the given X509 CRL.
 * @param validationDate
 *            the validate date.
 * @return <code>true</code> if integrity is OK, <code>false</code>
 *         otherwise.
 */
public static boolean checkCrlIntegrity(X509CRL x509crl, X509Certificate issuerCertificate,
        Date validationDate) {
    if (false == x509crl.getIssuerX500Principal().equals(issuerCertificate.getSubjectX500Principal())) {
        return false;
    }
    try {
        x509crl.verify(issuerCertificate.getPublicKey());
    } catch (Exception e) {
        return false;
    }
    Date thisUpdate = x509crl.getThisUpdate();
    LOG.debug("validation date: " + validationDate);
    LOG.debug("CRL this update: " + thisUpdate);
    if (thisUpdate.after(validationDate)) {
        LOG.warn("CRL too young");
        return false;
    }
    LOG.debug("CRL next update: " + x509crl.getNextUpdate());
    if (validationDate.after(x509crl.getNextUpdate())) {
        LOG.debug("CRL too old");
        return false;
    }

    // assert cRLSign KeyUsage bit
    if (null == issuerCertificate.getKeyUsage()) {
        LOG.debug("No KeyUsage extension for CRL issuing certificate");
        return false;
    }

    if (false == issuerCertificate.getKeyUsage()[6]) {
        LOG.debug("cRLSign bit not set for CRL issuing certificate");
        return false;
    }

    return true;
}

From source file:com.adobe.acs.commons.mcp.impl.processes.RefreshFolderTumbnails.java

protected static boolean isAssetMissingOrNewer(Resource asset, Date compareDate) {
    if (asset == null) {
        scanResult.set("Referenced asset missing");
        return true;
    } else {/*from  ww w .  j a v a2s . co m*/
        Resource content = asset.getChild("jcr:content");
        if (content == null) {
            scanResult.set("Referenced asset has no content node; " + asset.getPath());
            return true;
        }
        Date assetModified = content.getValueMap().get("jcr:lastModified", Date.class);
        if (assetModified == null) {
            scanResult.set("Referenced asset has no modified date; " + asset.getPath());
            return true;
        } else if (assetModified.after(compareDate)) {
            scanResult.set("Referenced newer than folder; " + asset.getPath());
            return true;
        }
    }
    return false;
}

From source file:org.jfrog.hudson.util.ExtractorUtils.java

private static long daysBetween(Date date1, Date date2) {
    long diff;/* w w  w  . j  a v a2 s  . co  m*/
    if (date2.after(date1)) {
        diff = date2.getTime() - date1.getTime();
    } else {
        diff = date1.getTime() - date2.getTime();
    }
    return diff / (24 * 60 * 60 * 1000);
}

From source file:com.github.tomakehurst.wiremock.testsupport.WireMatchers.java

public static Matcher<Date> isAfter(final String dateString) {
    return new TypeSafeMatcher<Date>() {
        @Override/*w  w w.ja  va2 s  . c  o m*/
        public boolean matchesSafely(Date date) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                Date compareDate = df.parse(dateString);
                return date.after(compareDate);
            } catch (ParseException pe) {
                throw new RuntimeException(pe);
            }
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("A date after " + dateString);
        }
    };
}

From source file:br.com.nordestefomento.jrimum.utilix.BancoUtil.java

/**
 * <p>//  w  ww .  j a  v  a  2  s . c o  m
 * Calcula o fator de vencimento a partir da subtrao entre a DATA DE
 * VENCIMENTO de um ttulo e a DATA BASE fixada em 07/10/1997.
 * </p>
 * 
 * <p>
 * O fator de vencimento nada mais  que um referencial numrico de 4
 * dgitos que representa a quantidade de dias decorridos desde a data base
 * (07/10/1997) at a data de vencimento do ttulo. Ou seja, a diferena em
 * dias entre duas datas.
 * </p>
 * 
 * <p>
 * Exemplos:
 * </p>
 * <ul type="circule"> <li>07/10/1997 (Fator = 0);</li> <li>03/07/2000
 * (Fator = 1000);</li> <li>05/07/2000 (Fator = 1002);</li> <li>01/05/2002
 * (Fator = 1667);</li> <li>21/02/2025 (Fator = 9999).</li> </ul>
 * 
 * <p>
 * Funcionamento:
 * </p>
 * 
 * <ul type="square"> <li>Caso a data de vencimento seja anterior a data
 * base (Teoricamente fator negativo), uma exceo do tipo
 * IllegalArgumentException ser lanada.</li> <li>A data limite para o
 * clculo do fator de vencimento  21/02/2025 (Fator de vencimento = 9999).
 * Caso a data de vencimento seja posterior a data limite, uma exceo do
 * tipo IllegalArgumentException ser lanada.</li> </ul>
 * 
 * <p>
 * <strong>ATENO</strong>, esse clculo se refere a ttulos em cobrana,
 * ou melhor: BOLETOS. Desta forma, lembramos que a DATA BASE  uma norma da
 * FEBRABAN. Essa norma diz que todos os boletos emitidos a partir de 1 de
 * setembro de 2000 (primeiro dia til = 03/07/2000 - SEGUNDA) devem seguir
 * esta regra de clculo para compor a informao de vencimento no cdigo de
 * barras. Portanto, boletos no padro FEBRABAN quando capturados por
 * sistemas da rede bancria permitem que se possa realizar a operao
 * inversa, ou seja, adicionar  data base o fator de vencimento capturado.
 * Obtendo ento a data de vencimento deste boleto.
 * </p>
 * 
 * @param dataVencimento
 *            data de vencimento de um ttulo
 * @return fator de vencimento calculado
 * @throws IllegalArgumentException
 * 
 * @since 0.2
 */

public static int calculceFatorDeVencimento(Date dataVencimento) throws IllegalArgumentException {

    Date dataVencTruncada = null;
    int fator;

    if (isNull(dataVencimento)) {
        throw new IllegalArgumentException(
                "Impossvel realizar o clculo do fator" + " de vencimento de uma data nula.");
    } else {
        dataVencTruncada = DateUtils.truncate(dataVencimento, Calendar.DATE);
        if (dataVencTruncada.before(DATA_BASE_DO_FATOR_DE_VENCIMENTO)
                || dataVencTruncada.after(DATA_LIMITE_DO_FATOR_DE_VENCIMENTO)) {
            throw new IllegalArgumentException(
                    "Para o clculo do fator de" + " vencimento se faz necessrio informar uma data entre"
                            + " " + DateUtil.FORMAT_DD_MM_YYYY.format(DATA_BASE_DO_FATOR_DE_VENCIMENTO) + " e "
                            + DateUtil.FORMAT_DD_MM_YYYY.format(DATA_LIMITE_DO_FATOR_DE_VENCIMENTO));
        } else {
            fator = (int) DateUtil.calculeDiferencaEmDias(DATA_BASE_DO_FATOR_DE_VENCIMENTO, dataVencTruncada);
        }
    }

    return fator;
}

From source file:com.aurel.track.fieldType.bulkSetters.DateBulkSetter.java

private static void calculateOffset(BulkTranformContext bulkTranformContext, Integer fieldID,
        Integer parameterCode, Object targetValue, boolean earliest) {
    List<TWorkItemBean> selectedWorkItems = bulkTranformContext.getSelectedWorkItems();
    Map<Integer, Object> valueCache = bulkTranformContext.getValueCache();
    Date targetDate = null;//  w  w w. ja  va2 s .co  m
    try {
        targetDate = (Date) targetValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the target value " + targetValue + " to Date failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (targetDate == null || selectedWorkItems == null) {
        //set to 0 to mark it as calculated (avoid finding the offset for each workItem). 0 means no change anyway
        valueCache.put(fieldID, Integer.valueOf(0));
        return;
    }
    Date extremeDate = null;
    for (TWorkItemBean workItemBean : selectedWorkItems) {
        Object value = workItemBean.getAttribute(fieldID, parameterCode);
        if (value != null) {
            Date actualDate = (Date) value;
            if (extremeDate == null) {
                extremeDate = actualDate;
            } else {
                if ((earliest && actualDate.before(extremeDate))
                        || !earliest && actualDate.after(extremeDate)) {
                    extremeDate = actualDate;
                }
            }
        }
    }
    if (extremeDate == null) {
        //set to 0 to mark it as calculated (avoid finding the offset for each workItem). 0 means no change anyway
        valueCache.put(fieldID, Integer.valueOf(0));
    } else {
        Calendar targetCalendar = Calendar.getInstance();
        targetCalendar.setTime(targetDate);
        Calendar extremeCalendar = Calendar.getInstance();
        extremeCalendar.setTime(extremeDate);
        long diff = targetCalendar.getTimeInMillis() - extremeCalendar.getTimeInMillis();
        //daylight saving correction
        double days = diff * 1.0 / (1000 * 60 * 60 * 24);
        int intDays = (int) Math.round(days);
        valueCache.put(fieldID, Integer.valueOf(intDays));
    }
}

From source file:com.evolveum.midpoint.schema.util.CertCampaignTypeUtil.java

public static Date getReviewedTimestamp(List<AccessCertificationWorkItemType> workItems) {
    Date lastDate = null;/*  ww w .  j a v a  2  s  .  c  o  m*/
    for (AccessCertificationWorkItemType workItem : workItems) {
        if (hasNoResponse(workItem)) {
            continue;
        }
        Date responseDate = XmlTypeConverter.toDate(workItem.getOutputChangeTimestamp());
        if (lastDate == null || responseDate.after(lastDate)) {
            lastDate = responseDate;
        }
    }
    return lastDate;
}

From source file:com.ibm.domino.das.resources.DocumentResource.java

static private String ifModifiedSince(Document document, final String ifModifiedSince) throws NotesException {
    String lastModifiedHeader = null;
    DateTime lastModifiedDateTime = document.getLastModified();
    if (lastModifiedDateTime != null) {
        Date lastModifiedDate = lastModifiedDateTime.toJavaDate();
        if (lastModifiedDate != null) {
            // Formats the given date according to the RFC 1123 pattern. 
            lastModifiedHeader = org.apache.http.impl.cookie.DateUtils.formatDate(lastModifiedDate);
            if (lastModifiedHeader != null) {
                if (ifModifiedSince != null) {
                    if (ifModifiedSince.equalsIgnoreCase(lastModifiedHeader)) {
                        throw new WebApplicationException(Response.Status.NOT_MODIFIED);
                    }// ww w .  j a v  a  2s. c  o m
                    try {
                        Date ifModifiedSinceDate = org.apache.http.impl.cookie.DateUtils
                                .parseDate(ifModifiedSince);
                        if (ifModifiedSinceDate.equals(lastModifiedDate)
                                || ifModifiedSinceDate.after(lastModifiedDate)) {
                            throw new WebApplicationException(Response.Status.NOT_MODIFIED);
                        }
                    } catch (DateParseException e) {
                        // If we can not parse the If-Modified-Since then continue.
                        DAS_LOGGER.info("Can not parse the If-Modified-Since header."); // $NON-NLS-1$
                    }
                }
            }
        }
    }
    return lastModifiedHeader;
}

From source file:DateUtil.java

/**
 * Tells you if the date part of a datetime is in a certain time range.
 *//*  w  ww. j  a  va  2  s. c  om*/
public static boolean isTimeInRange(java.sql.Time start, java.sql.Time end, java.util.Date d) {
    d = new java.sql.Time(d.getHours(), d.getMinutes(), d.getSeconds());

    if (start == null || end == null) {
        return false;
    }

    if (start.before(end) && (!(d.after(start) && d.before(end)))) {
        return false;
    }

    if (end.before(start) && (!(d.after(end) || d.before(start)))) {
        return false;
    }
    return true;
}

From source file:de.micromata.genome.util.types.DateUtils.java

/**
 * If one of the date is null, it returns the other.
 *
 * @param left the left//from  www  . ja va 2 s .  co m
 * @param right the right
 * @return smaller of both dates.
 */
public static Date min(final Date left, final Date right) {
    if (left == null) {
        return right;
    }
    if (right == null) {
        return left;
    }
    if (left.after(right) == true) {
        return right;
    } else {
        return left;
    }
}