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:Main.java

/**
 * Tests if the given base date is strictly between the given start date and
 * end date.//from   w  ww .  j a  v a 2s  .c o m
 *
 * @param baseDate  the date used as base for the test.
 * @param startDate the start date.
 * @param endDate   the end date.
 * @return <code>true</code> if the base date is between the start date
 * and end date, <code>false</code> otherwise.
 */
public static boolean strictlyBetween(Date baseDate, Date startDate, Date endDate) {
    if (startDate.equals(endDate) || endDate.before(startDate)) {
        return false;
    }

    if (startDate.before(baseDate) && endDate.after(baseDate)) {
        return true;
    }

    return false;
}

From source file:fi.vm.sade.organisaatio.service.util.OrganisaatioUtil.java

/**
 * Organisaation lakkautuspvm -logiikka. Huom. kaikki parametrit voivat olla null.
 *
 * @param oldLpvm Pivitettvn organisaation nykyinen lakkautuspvm.
 * @param newLpvm Uusi lakkautuspvm.//from w w  w .  ja  va  2  s . c o  m
 * @param origLpvm Pivitettvn organisaatiojoukun alkuperinen lakkautuspvm.
 * @param parentLpvm Ylemmn tason organisaation lakkautuspvm.
 * @return
 */
public static Date getUpdatedLakkautusPvm(Date oldLpvm, Date newLpvm, Date origLpvm, Date parentLpvm) {
    if (parentLpvm != null && (newLpvm == null || newLpvm.after(parentLpvm))) {
        newLpvm = parentLpvm;
    }
    if (origLpvm != null && !isSameDay(oldLpvm, origLpvm)) {
        return oldLpvm;
    } else {
        return newLpvm;
    }
}

From source file:com.castis.xylophone.adsmadapter.common.util.CiDateUtil.java

public static boolean checkFutureDate(String date, String format) {
    if (date == null || date.isEmpty() == true)
        return false;

    Date tmpDate = convertDate(date, format);
    Date curDate = DateUtil.getCurDate();

    return tmpDate.after(curDate);
}

From source file:Main.java

public static boolean isCACertificateInstalled(File fileCA, String type, char[] password)
        throws KeyStoreException {

    KeyStore keyStoreCA = null;//from   w  ww  .  j ava  2 s . com
    try {
        keyStoreCA = KeyStore.getInstance(type/*, "BC"*/);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (fileCA.exists() && fileCA.canRead()) {
        try {
            FileInputStream fileCert = new FileInputStream(fileCA);
            keyStoreCA.load(fileCert, password);
            fileCert.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (java.security.cert.CertificateException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Enumeration ex = keyStoreCA.aliases();
        Date exportFilename = null;
        String caAliasValue = "";

        while (ex.hasMoreElements()) {
            String is = (String) ex.nextElement();
            Date lastStoredDate = keyStoreCA.getCreationDate(is);
            if (exportFilename == null || lastStoredDate.after(exportFilename)) {
                exportFilename = lastStoredDate;
                caAliasValue = is;
            }
        }

        try {
            return keyStoreCA.getKey(caAliasValue, password) != null;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnrecoverableKeyException e) {
            e.printStackTrace();
        }
    }
    return false;
}

From source file:Main.java

public static int compareDates(String startDateString, String endDateString) {
    int interval = 0;

    if (TextUtils.isEmpty(startDateString) || TextUtils.isEmpty(endDateString)) {
        return -1;
    }/*from w  ww.  j a v  a 2 s  . c om*/
    try {
        java.util.Date startDate = dateFormat.parse(startDateString);
        java.util.Date endDate = dateFormat.parse(endDateString);

        if (startDate.after(endDate)) {
            return -1;
        }

        interval = compareDates(startDate, endDate);

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return interval;
}

From source file:io.milton.http.annotated.CTagAnnotationHandler.java

public static String deriveCtag(CollectionResource col) throws NotAuthorizedException, BadRequestException {
    Date latest = col.getModifiedDate();
    for (Resource r : col.getChildren()) {
        Date d = r.getModifiedDate();
        if (d != null) {
            if (latest == null || d.after(latest)) {
                latest = d;//from   www.j  a  va 2 s  .  com
            }
        }
    }

    String ctag = null;
    if (latest != null) {
        ctag = "T" + latest.getTime();
    }
    return ctag;
}

From source file:edu.zipcloud.core.util.DateUtil.java

public static boolean isRecent(Date date, int nbMinutes) {
    if (date == null) {
        throw new IllegalArgumentException("date parameter cannot be null!");
    }//  ww  w  .java2s. c  o m
    return date.after(getXMinPriorDate(new Date(), nbMinutes));
}

From source file:Main.java

public static boolean isDateLatest(Date nextSigDate, Date latestSigDate) {
    if (nextSigDate == null) {
        return false;
    }//from   w  ww  .  jav  a  2s . c  o  m

    if (latestSigDate == null) {
        return true;
    }

    return nextSigDate.after(latestSigDate);
}

From source file:Main.java

/**
 * Validate the token expiration date./*w w w . j  a va  2s.  c  o  m*/
 *
 * @param expirationDate - Token expiration date.
 * @return - Token status.
 */
public static boolean isValid(Date expirationDate) {
    Date currentDate = new Date();
    String formattedDate = dateFormat.format(currentDate);
    currentDate = convertDate(formattedDate);

    boolean isExpired = currentDate.after(expirationDate);
    boolean isEqual = currentDate.equals(expirationDate);
    if (isExpired == true || isEqual == true) {
        return true;
    }

    return false;
}

From source file:Main.java

/**
 * Tests if the given base date is between the given start date and end
 * date, including the dates themselves.
 *
 * @param baseDate  the date used as base for the test.
 * @param startDate the start date.//from w  w  w  .  j a v a2 s . co  m
 * @param endDate   the end date.
 * @return <code>true</code> if the base date is between the start date
 * and end date, <code>false</code> otherwise.
 */
public static boolean between(Date baseDate, Date startDate, Date endDate) {
    if (startDate.equals(endDate) || endDate.before(startDate)) {
        return false;
    }

    if ((startDate.before(baseDate) || startDate.equals(baseDate))
            && (endDate.after(baseDate) || endDate.equals(baseDate))) {
        return true;
    }

    return false;
}