Example usage for java.util Date equals

List of usage examples for java.util Date equals

Introduction

In this page you can find the example usage for java.util Date equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares two dates for equality.

Usage

From source file:org.openmrs.module.kenyaemr.util.KenyaEmrUtils.java

/**
 * Checks whether a date has any time value
 * @param date the date/* w  ww.jav  a2s  .co m*/
 * @return true if the date has time
 * @should return true only if date has time
 */
public static boolean dateHasTime(Date date) {
    return !date.equals(OpenmrsUtil.firstSecondOfDay(date));
}

From source file:Main.java

/**
 * Validate the token expiration date.//from  ww w.  j av  a 2  s. 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:com.amazonaws.util.JodaTime.java

private static boolean checkFormatIso8601Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String expected = sdf.format(date);
    String actual = DateUtils.iso8601DateFormat.print(date.getTime());
    if (expected.equals(actual)) {
        Date expectedDate = sdf.parse(expected);
        Date actualDate = DateUtils.doParseISO8601Date(actual);
        return expectedDate.equals(actualDate);
    }/*from  w  ww  .  j  ava 2 s . co  m*/
    return false;
}

From source file:com.amazonaws.util.JodaTime.java

private static boolean checkParseIso8601DateUsingAlternativeFormat() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String formatted = sdf.format(date);
    String alternative = DateUtils.alternateIso8601DateFormat.print(date.getTime());
    if (formatted.equals(alternative)) {
        Date expectedDate = sdf.parse(formatted);
        Date actualDate = DateUtils.parseISO8601Date(formatted);
        return expectedDate.equals(actualDate);
    }/*from   w  ww.ja  v  a 2  s. co m*/
    return false;
}

From source file:com.amazonaws.util.JodaTime.java

private static boolean checkParseIso8601Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String formatted = sdf.format(date);
    String alternative = DateUtils.iso8601DateFormat.print(date.getTime());
    if (formatted.equals(alternative)) {
        Date expectedDate = sdf.parse(formatted);
        Date actualDate = DateUtils.doParseISO8601Date(formatted);
        return expectedDate.equals(actualDate);
    }/* w w  w.ja va2 s  .  c  om*/
    return false;
}

From source file:com.amazonaws.util.JodaTime.java

private static boolean checkParseRfc822Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String formatted = sdf.format(date);
    Date expected = sdf.parse(formatted);
    Date actual2 = new Date(DateUtils.rfc822DateFormat.parseMillis(formatted));
    return expected.equals(actual2);
}

From source file:org.openmrs.module.kenyaemr.util.KenyaEmrUtils.java

/**
 * Checks found CIEL version against the required version.
 * @param required the required version//from w ww  . java2s .  com
 * @param found the found version
 * @return true if found version is equal or greater to the required version
 */
public static boolean checkCielVersions(String required, String found) {
    DateFormat format = new SimpleDateFormat("yyyyMMdd");
    try {
        Date requiredDate = format.parse(required);
        Date foundDate = format.parse(found);

        return foundDate.equals(requiredDate) || foundDate.after(requiredDate);
    } catch (Exception e) {
        return false;
    }
}

From source file:com.amazonaws.util.JodaTime.java

private static boolean checkParseCompressedIso8601Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String formatted = sdf.format(date);
    Date expected = sdf.parse(formatted);
    Date actual = new Date(DateUtils.compressedIso8601DateFormat.parseMillis(formatted));
    return expected.equals(actual);
}

From source file:com.amazonaws.util.JodaTime.java

private static boolean checkFormatRfc822Date() throws ParseException {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
    sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
    String expected = sdf.format(date);
    String actual = DateUtils.rfc822DateFormat.print(date.getTime());
    if (expected.equals(actual)) {
        Date expectedDate = sdf.parse(expected);
        Date actualDate2 = new Date(DateUtils.rfc822DateFormat.parseMillis(actual));
        return expectedDate.equals(actualDate2);
    }//from w w  w .j a v  a 2s. co  m
    return false;
}

From source file:org.egov.infra.utils.DateUtils.java

public static boolean between(Date date, Date fromDate, Date toDate) {
    return (date.after(fromDate) || date.equals(fromDate)) && date.before(toDate) || date.equals(toDate);
}