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

public static boolean inBetweenDate(Calendar first, Calendar last) {

    Date min = first.getTime();/*from  w w  w .  j a  v a 2 s. co  m*/
    Date max = last.getTime();

    boolean check = max.before(min);
    boolean check2 = max.equals(min);

    return !(check || check2);
}

From source file:Main.java

public static int compareDate(Date date, Date oldDate) {
    if (oldDate.after(date)) {
        return 1;
    } else if (oldDate.equals(date)) {
        return 0;
    } else {/*  w  w w.  jav  a 2s  . com*/
        return -1;
    }
}

From source file:com.apabi.r2k.common.security.util.NonceUtils.java

/**
 * Hex??Counter./*  w ww  .  j a  va 2s .co  m*/
 */
public static synchronized String getCounter() {
    Date currentTime = new Date();

    if (currentTime.equals(lastTime)) {
        counter++;
    } else {
        lastTime = currentTime;
        counter = 0;
    }
    return Integer.toHexString(counter);
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static boolean isSameDay(Date first, Date second) {
    if ((first == null || second == null) && !first.equals(second)) {
        return false;
    }//  w  w w.  j  a v  a 2  s  .c  o  m
    Date firstDay = DateUtils.truncate(first, Calendar.DAY_OF_MONTH);
    Date secondDay = DateUtils.truncate(second, Calendar.DAY_OF_MONTH);
    return firstDay.equals(secondDay);
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static boolean isSameMonth(Date first, Date second) {
    if ((first == null || second == null) && !first.equals(second)) {
        return false;
    }//from w  w w . j av a 2 s . c o m
    Date firstMonth = DateUtils.truncate(first, Calendar.MONTH);
    Date secondMonth = DateUtils.truncate(second, Calendar.MONTH);
    return firstMonth.equals(secondMonth);
}

From source file:nu.mine.kino.projects.utils.BaseDataUtilsTest.java

private static void print(Task task) throws ParseException {

    Date[] projectRange = BaseDataUtils.getProjectRange(task.getPlotDataMap());

    System.out.print("Date: ");
    Date targetDate = projectRange[0];
    while (!targetDate.equals(projectRange[1])) {
        System.out.printf("[%s] ", Utils.date2Str(targetDate, "MM/dd"));
        targetDate = DateUtils.addDays(targetDate, 1);
    }//from w w w.ja va2s  .com
    System.out.println();

    System.out.print("?XPV: ");
    targetDate = projectRange[0];
    while (!targetDate.equals(projectRange[1])) {
        double pv = ProjectUtils.calculatePV(task, targetDate);
        System.out.printf("[%1$,.1f] ", pv);
        targetDate = DateUtils.addDays(targetDate, 1);
    }
    System.out.println();

    // String[] dates = { "20140901", "20140902", "20140903", "20140904",
    // "20140905", "20140906", "20140907", "20140908", "20140909",
    // "20140910", "20140911", "20140912", "20140913", "20140914",
    // "20140915", "20140916", "20140917", "20140918", "20140919",
    // "20140920", "20140921", "20140922", "20140923", "20140924",
    // "20140925", "20140926", "20140927", "20140928", "20140929",
    // "20140930" };
    // System.out.print("?XPV: ");
    // for (String date : dates) {
    // Date baseDate = DateUtils.parseDate(date,
    // new String[] { "yyyyMMdd" });
    // double pv = ProjectUtils.calculatePV(task, baseDate);
    // System.out.printf("[%1$,.1f] ", pv);
    // }
    // System.out.println();
    // System.out.print("?PV: ");
    // for (String date : dates) {
    // Date baseDate = DateUtils.parseDate(date,
    // new String[] { "yyyyMMdd" });
    // double pvs = ProjectUtils.calculatePVs(task, baseDate);
    // System.out.printf("[%1$,.1f] ", pvs);
    // }
    // System.out.println();
}

From source file:org.kuali.student.enrollment.class2.acal.util.AcalCommonUtils.java

public static boolean isDateWithinRange(Date startDate, Date endDate, Date checkDate) {
    if (startDate != null && endDate != null && checkDate != null) {
        if ((!checkDate.equals(startDate) && checkDate.before(startDate))
                || (!checkDate.equals(endDate) && checkDate.after(endDate))) {
            return false;
        }//from   w  w  w  .j a v a  2 s . c om
    }
    return true;
}

From source file:org.apache.lens.cube.parse.QueriedPhraseContext.java

public static boolean isColumnAvailableTill(@NonNull final Date date, Date endTime) {
    return (endTime == null) || date.equals(endTime) || date.before(endTime);
}

From source file:org.apache.lens.cube.parse.QueriedPhraseContext.java

public static boolean isColumnAvailableFrom(@NonNull final Date date, Date startTime) {
    return (startTime == null) || date.equals(startTime) || date.after(startTime);
}

From source file:net.duckling.ddl.util.AoneTimeUtils.java

public static boolean isSameYear(Date first, Date second) {
    if ((first == null || second == null) && first != second) {
        return false;
    }//from ww w.  ja  v  a 2  s  .  c o  m
    Date firstYear = DateUtils.truncate(first, Calendar.YEAR);
    Date secondYear = DateUtils.truncate(second, Calendar.YEAR);
    return firstYear.equals(secondYear);
}