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:com.linuxbox.enkive.filter.EnkiveFilter.java

private boolean filterDate(String value) throws java.text.ParseException {
    boolean matched = false;

    Date dateValue = dateFormatter.parse(value);
    Date dateFilterValue = dateFormatter.parse(filterValue);

    switch (filterComparator) {
    case FilterComparator.MATCHES:
        if (dateValue.equals(dateFilterValue))
            matched = true;//from  www  .  j  a v  a2s.  co  m
        break;
    case FilterComparator.DOES_NOT_MATCH:
        if (!dateValue.equals(dateFilterValue))
            matched = true;
        break;
    case FilterComparator.IS_GREATER_THAN:
        if (dateValue.after(dateFilterValue))
            matched = true;
        break;
    case FilterComparator.IS_LESS_THAN:
        if (dateValue.before(dateFilterValue))
            matched = true;
        break;
    }
    return matched;
}

From source file:StockForecast.User.java

private void checkDateCond(String prevDate, Date today, Date start, Date end) throws Exception {
    if (start.equals(end)) {
        JOptionPane.showMessageDialog(this, "Please Select Range Date");
    } else if (start.equals(today)) {
        JOptionPane.showMessageDialog(this, "Please Select : (" + prevDate + ") as a Maximum Date");
    } else if (end.equals(today)) {
        JOptionPane.showMessageDialog(this, "Please Select : (" + prevDate + ") as a Maximum Date");
    } else if (start.compareTo(end) > 0) {
        JOptionPane.showMessageDialog(this, "Start Date is After End Date, Please Select Proper Range Date");
    } else {/*  ww  w. ja v a  2  s .  c  o m*/
        System.out.println("Mari Berpesta" + "\n" + today + "\n" + start + "\n" + end);
        loopSymbol(start, end);
    }
}

From source file:net.chaosserver.timelord.swingui.SummaryPanel.java

/**
 * Checks if the date being displayed is equal to the start of the current
 * time.//w w w . j a va 2s. c  o  m
 *
 * @return indicates if the date is the start of the current time
 */
public boolean isToday() {
    boolean result = false;

    Date todayDate = DateUtil.trunc(new Date());

    if (log.isTraceEnabled()) {
        log.trace("Testing today [" + todayDate + "] compared to " + "dateDisplayed [" + getDateDisplayed()
                + "]");
    }

    if (todayDate.equals(getDateDisplayed())) {
        result = true;
    }

    return result;
}

From source file:org.jfree.data.time.junit.DayTest.java

/**
 * Problem for date parsing./*from  w  ww  . ja va2s  .com*/
 * <p>
 * This test works only correct if the short pattern of the date
 * format is "dd/MM/yyyy". If not, this test will result in a
 * false negative.
 *
 * @throws ParseException on parsing errors.
 */
public void testParseDay() throws ParseException {
    GregorianCalendar gc = new GregorianCalendar(2001, 12, 31);
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
    Date reference = format.parse("31/12/2001");
    if (reference.equals(gc.getTime())) {
        // test 1...
        Day d = Day.parseDay("31/12/2001");
        assertEquals(37256, d.getSerialDate().toSerial());
    }

    // test 2...
    Day d = Day.parseDay("2001-12-31");
    assertEquals(37256, d.getSerialDate().toSerial());
}

From source file:org.apache.ws.security.message.token.Timestamp.java

private boolean compare(Date item1, Date item2) {
    if (item1 == null && item2 != null) {
        return false;
    } else if (item1 != null && !item1.equals(item2)) {
        return false;
    }/*from w  w  w.j a v a2  s .c o m*/
    return true;
}

From source file:at.stefanproell.PersistentIdentifierMockup.TimeStampInterceptor.java

/**
 * Store the timestamp of an update/*www .j a va2s. co  m*/
 *
 * @param entity
 * @param id
 * @param currentState
 * @param previousState
 * @param propertyNames
 * @param types
 * @return
 */
@Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState,
        String[] propertyNames, Type[] types) {

    /**
     * Update the lastUpdateDate value and set the wasUpdated flag to 'Y'
     */
    if (entity instanceof TimeStamped && previousState != null) {
        logger.info("UPDATE operation");
        /*
        logger.info("onFlushDirty: Object Details are as below: ");
                
        for (int i = 0; i < length; i++) {
        logger.info("onFlushDirty[" + i + "]: propertyName : " + propertyNames[i]
                + " ,type :  " + types[i]
                + " , previous state : " + previousState[i]
                + " , current state : " + currentState[i]);
        }
        */

        int indexOfLastUpdate = ArrayUtils.indexOf(propertyNames, "lastUpdatedDate");
        int indexOfCreatedDate = ArrayUtils.indexOf(propertyNames, "createdDate");
        int indexOfWasUpdated = ArrayUtils.indexOf(propertyNames, "wasUpdated");

        Date createdDate = (Date) previousState[indexOfCreatedDate];
        Date lastUpdateDate = (Date) currentState[indexOfLastUpdate];

        /**
         * If createdDate equals lastUpdateDate, this is the first update.
         * Set the updated column to Y
         */
        if (createdDate.equals(lastUpdateDate)) {
            logger.warning("This is the first update of the record.");
            currentState[indexOfWasUpdated] = 'Y';
        }
        // set the new date of the update event
        currentState[indexOfLastUpdate] = new Date();

        return true;
    }
    return false;
}

From source file:com.janela.mobile.ui.gist.GistFragment.java

private void updateHeader(Gist gist) {
    Date createdAt = gist.getCreatedAt();
    if (createdAt != null) {
        StyledText text = new StyledText();
        text.append(getString(R.string.prefix_created));
        text.append(createdAt);/*w w w . j ava  2s .c  om*/
        created.setText(text);
        created.setVisibility(VISIBLE);
    } else
        created.setVisibility(GONE);

    Date updatedAt = gist.getUpdatedAt();
    if (updatedAt != null && !updatedAt.equals(createdAt)) {
        StyledText text = new StyledText();
        text.append(getString(R.string.prefix_updated));
        text.append(updatedAt);
        updated.setText(text);
        updated.setVisibility(VISIBLE);
    } else
        updated.setVisibility(GONE);

    String desc = gist.getDescription();
    if (!TextUtils.isEmpty(desc))
        description.setText(desc);
    else
        description.setText(R.string.no_description_given);

    ViewUtils.setGone(progress, true);
    ViewUtils.setGone(list, false);
}

From source file:com.github.mobile.ui.gist.GistFragment.java

private void updateHeader(Gist gist) {
    Date createdAt = gist.getCreatedAt();
    if (createdAt != null) {
        StyledText text = new StyledText();
        text.append(getString(string.prefix_created));
        text.append(createdAt);/*from  w  w w . jav a 2  s .  c  o m*/
        created.setText(text);
        created.setVisibility(VISIBLE);
    } else
        created.setVisibility(GONE);

    Date updatedAt = gist.getUpdatedAt();
    if (updatedAt != null && !updatedAt.equals(createdAt)) {
        StyledText text = new StyledText();
        text.append(getString(string.prefix_updated));
        text.append(updatedAt);
        updated.setText(text);
        updated.setVisibility(VISIBLE);
    } else
        updated.setVisibility(GONE);

    String desc = gist.getDescription();
    if (!TextUtils.isEmpty(desc))
        description.setText(desc);
    else
        description.setText(string.no_description_given);

    ViewUtils.setGone(progress, true);
    ViewUtils.setGone(list, false);
}

From source file:org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter.java

private void mergeEntryWithKey(ImportKeysListEntry entry, CanonicalizedKeyRing keyRing) {
    entry.setRevoked(keyRing.isRevoked());
    entry.setExpired(keyRing.isExpired());

    Date expectedDate = entry.getDate();
    Date creationDate = keyRing.getCreationDate();
    if (expectedDate == null) {
        entry.setDate(creationDate);/*from w w w. j av a2 s.  co m*/
    } else if (!expectedDate.equals(creationDate)) {
        throw new AssertionError("Creation date doesn't match the expected one");
    }
    entry.setKeyId(keyRing.getMasterKeyId());

    ArrayList<String> realUserIdsPlusKeybase = keyRing.getUnorderedUserIds();
    realUserIdsPlusKeybase.addAll(entry.getKeybaseUserIds());
    entry.setUserIds(realUserIdsPlusKeybase);
}

From source file:admin.jmx.SimpleJobExecutionMetrics.java

private StepExecution getLatestStepExecution(JobExecution jobExecution) {
    Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions();
    StepExecution stepExecution = null;/* w  w w. j av a2s .co m*/
    if (!stepExecutions.isEmpty()) {
        Date latest = new Date(0L);
        for (StepExecution candidate : stepExecutions) {
            Date stepDate = candidate.getEndTime();
            stepDate = stepDate == null ? new Date() : stepDate;
            if (stepDate.after(latest)) {
                latest = stepDate;
                stepExecution = candidate;
            } else if (stepExecution != null && stepDate.equals(latest)
                    && candidate.getId() > stepExecution.getId()) {
                // Tie breaker using ID
                stepExecution = candidate;
            }
        }
    }
    return stepExecution;
}