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.apigee.sdk.apm.http.impl.client.cache.ResponseProtocolCompliance.java

private void warningsWithNonMatchingWarnDatesAreRemoved(HttpResponse response) {
    Date responseDate = null;/*w ww .j  ava  2  s.  co  m*/
    try {
        responseDate = DateUtils.parseDate(response.getFirstHeader("Date").getValue());
    } catch (DateParseException e) {
    }
    if (responseDate == null)
        return;
    Header[] warningHeaders = response.getHeaders("Warning");
    if (warningHeaders == null || warningHeaders.length == 0)
        return;
    List<Header> newWarningHeaders = new ArrayList<Header>();
    boolean modified = false;
    for (Header h : warningHeaders) {
        for (WarningValue wv : WarningValue.getWarningValues(h)) {
            Date warnDate = wv.getWarnDate();
            if (warnDate == null || warnDate.equals(responseDate)) {
                newWarningHeaders.add(new BasicHeader("Warning", wv.toString()));
            } else {
                modified = true;
            }
        }
    }
    if (modified) {
        response.removeHeaders("Warning");
        for (Header h : newWarningHeaders) {
            response.addHeader(h);
        }
    }
}

From source file:com.espertech.esper.schedule.TestScheduleComputeHelper.java

public void checkCorrect(ScheduleSpec spec, String now, String expected) throws Exception {
    Date nowDate = timeFormat.parse(now);
    Date expectedDate = timeFormat.parse(expected);

    long result = ScheduleComputeHelper.computeNextOccurance(spec, nowDate.getTime());
    Date resultDate = new Date(result);

    if (!(resultDate.equals(expectedDate))) {
        log.debug(".checkCorrect Difference in result found, spec=" + spec);
        log.debug(".checkCorrect      now=" + timeFormat.format(nowDate) + " long=" + nowDate.getTime());
        log.debug(".checkCorrect expected=" + timeFormat.format(expectedDate) + " long="
                + expectedDate.getTime());
        log.debug(".checkCorrect   result=" + timeFormat.format(resultDate) + " long=" + resultDate.getTime());
        assertTrue(false);/*  w w  w. j  av a 2 s  .c  o m*/
    }
}

From source file:org.libreplan.business.qualityforms.entities.TaskQualityForm.java

public boolean isLaterToPreviousItemDate(TaskQualityFormItem item) {
    Integer previousPosition = item.getPosition() - 1;
    if ((previousPosition >= 0) && (previousPosition < taskQualityFormItems.size())) {
        Date previousDate = taskQualityFormItems.get(previousPosition).getDate();
        return (previousDate != null) && (item.getDate() != null)
                && ((previousDate.before(item.getDate())) || (previousDate.equals(item.getDate())));
    }//from w w  w .ja  v a 2s  . c  o  m

    return true;
}

From source file:net.sourceforge.jaulp.lang.ObjectUtilsTest.java

/**
 * Test clone object.// w ww .ja  v  a 2s  .  com
 */
@Test(enabled = false)
public void testCloneObject() {
    Date past = CreateDateUtils.newDate(2009, 3, 26, 10, 37, 04);
    Object otherCopy = ObjectUtils.cloneObjectQuietly(past);

    boolean result = past.equals(otherCopy);
    AssertJUnit.assertTrue("Cloned object should be equal with the source object.", result);

    String aString = "Hy there...";

    otherCopy = ObjectUtils.cloneObjectQuietly(aString);

    result = aString.equals(otherCopy);
    AssertJUnit.assertTrue("Cloned object should be equal with the source object.", result);

    A a = new A();
    a.setA("a");

    Object anotherCopy = ObjectUtils.cloneObjectQuietly(a);

    result = a.equals(anotherCopy);
    AssertJUnit.assertTrue("Cloned object should be equal with the source object.", result);
}

From source file:com.unilever.audit.entities.Items.java

@XmlTransient
private String getStatus(Date modifieddate, Date creationDate, boolean isDeleted) {
    if (isDeleted)
        status = "D";
    else if (modifieddate.equals(creationDate))
        status = "I";
    else//from w  ww  .j  av a2  s. com
        status = "U";
    return status;
}

From source file:technology.tikal.gae.http.cache.AbstractCacheController.java

protected boolean safeEqualsDates(Date a, Date b) {
    if (a == null && b == null) {
        return true;
    }//from w  w  w . j av a  2 s  .c o  m
    if (a == null || b == null) {
        return false;
    }
    return a.equals(b);
}

From source file:org.apache.http.impl.client.cache.ResponseCachingPolicy.java

private boolean expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl(HttpResponse response) {
    if (response.getFirstHeader("Cache-Control") != null)
        return false;
    Header expiresHdr = response.getFirstHeader("Expires");
    Header dateHdr = response.getFirstHeader("Date");
    if (expiresHdr == null || dateHdr == null)
        return false;
    try {/*from  w  w w. j ava2s .c o m*/
        Date expires = DateUtils.parseDate(expiresHdr.getValue());
        Date date = DateUtils.parseDate(dateHdr.getValue());
        return expires.equals(date) || expires.before(date);
    } catch (DateParseException dpe) {
        return false;
    }
}

From source file:org.polymap.rhei.field.DateTimeFormField.java

public Control createControl(Composite parent, IFormToolkit toolkit) {
    datetime = toolkit.createDateTime(parent, new Date(), SWT.MEDIUM | SWT.DROP_DOWN);
    datetime.setEnabled(enabled);/*from  w ww.  ja  v a2 s.c  o m*/
    //        datetime.setBackground( enabled ? FormEditorToolkit.textBackground : FormEditorToolkit.textBackgroundDisabled );

    // selection(modify) listener
    datetime.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Calendar cal = Calendar.getInstance(Locale.GERMANY);
            cal.set(datetime.getYear(), datetime.getMonth(), datetime.getDay(), datetime.getHours(),
                    datetime.getMinutes(), datetime.getSeconds());
            Date date = cal.getTime();
            log.info("widgetSelected(): test= " + date);

            site.fireEvent(DateTimeFormField.this, IFormFieldListener.VALUE_CHANGE,
                    loadedValue == null && date.equals(nullValue) ? null : date);
        }

    });
    // focus listener
    datetime.addFocusListener(new FocusListener() {
        public void focusLost(FocusEvent event) {
            //                datetime.setBackground( FormEditorToolkit.textBackground );
            site.fireEvent(DateTimeFormField.this, IFormFieldListener.FOCUS_LOST, null);
        }

        public void focusGained(FocusEvent event) {
            //                datetime.setBackground( FormEditorToolkit.textBackgroundFocused );
            site.fireEvent(DateTimeFormField.this, IFormFieldListener.FOCUS_GAINED, null);
        }
    });
    return datetime;
}

From source file:de.alpharogroup.lang.ObjectExtensionsTest.java

/**
 * Test clone object.//ww w .  j  a  va2s .co m
 */
@Test(enabled = true)
public void testCloneObject() {
    final Date past = CreateDateUtils.newDate(2009, 3, 26, 10, 37, 04);
    Object otherCopy = past.cloneObjectQuietly();

    boolean result = past.equals(otherCopy);
    AssertJUnit.assertTrue("Cloned object should be equal with the source object.", result);

    final String aString = "Hy there...";

    otherCopy = ObjectExtensions.cloneObjectQuietly(aString);

    result = aString.equals(otherCopy);
    AssertJUnit.assertTrue("Cloned object should be equal with the source object.", result);

    final A a = new A();
    a.setA("a");

    final Object anotherCopy = ObjectExtensions.cloneObjectQuietly(a);

    result = a.equals(anotherCopy);
    AssertJUnit.assertTrue("Cloned object should be equal with the source object.", result);
}

From source file:org.b3log.solo.util.Articles.java

/**
 * Determines the specified article has updated.
 *
 * @param article the specified article//from   w  w w  .  j  a v  a  2 s . co m
 * @return {@code true} if it has updated, {@code false} otherwise
 * @throws JSONException json exception
 */
public boolean hasUpdated(final JSONObject article) throws JSONException {
    final Date updateDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE);
    final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE);

    return !createDate.equals(updateDate);
}