Example usage for java.util Calendar equals

List of usage examples for java.util Calendar equals

Introduction

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

Prototype

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object obj) 

Source Link

Document

Compares this Calendar to the specified Object.

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.CFAccPhoneTagHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFAccPhoneTagHPKey) {
        CFAccPhoneTagHPKey rhs = (CFAccPhoneTagHPKey) obj;
        {//w w  w. j  a  va 2 s .co  m
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredPhoneId() != rhs.getRequiredPhoneId()) {
            return (false);
        }
        if (getRequiredTagId() != rhs.getRequiredTagId()) {
            return (false);
        }
        return (true);
    } else if (obj instanceof CFAccHPKey) {
        CFAccHPKey rhs = (CFAccHPKey) obj;
        {
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else if (obj instanceof CFAccPhoneTagPKey) {
        CFAccPhoneTagPKey rhs = (CFAccPhoneTagPKey) obj;
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredPhoneId() != rhs.getRequiredPhoneId()) {
            return (false);
        }
        if (getRequiredTagId() != rhs.getRequiredTagId()) {
            return (false);
        }
        return (true);
    } else if (obj instanceof CFAccPhoneTagHBuff) {
        CFAccPhoneTagHBuff rhs = (CFAccPhoneTagHBuff) obj;
        {
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredPhoneId() != rhs.getRequiredPhoneId()) {
            return (false);
        }
        if (getRequiredTagId() != rhs.getRequiredTagId()) {
            return (false);
        }
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredPhoneId() != rhs.getRequiredPhoneId()) {
            return (false);
        }
        if (getRequiredTagId() != rhs.getRequiredTagId()) {
            return (false);
        }
        return (true);
    } else if (obj instanceof CFAccPhoneTagBuff) {
        CFAccPhoneTagBuff rhs = (CFAccPhoneTagBuff) obj;
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredPhoneId() != rhs.getRequiredPhoneId()) {
            return (false);
        }
        if (getRequiredTagId() != rhs.getRequiredTagId()) {
            return (false);
        }
        return (true);
    } else {
        return (false);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.CFAccAccountEntryHPKey.java

public boolean equals(Object obj) {
    if (obj == null) {
        return (false);
    } else if (obj instanceof CFAccAccountEntryHPKey) {
        CFAccAccountEntryHPKey rhs = (CFAccAccountEntryHPKey) obj;
        {/*from   w w w . ja v a 2 s. com*/
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredAccountId() != rhs.getRequiredAccountId()) {
            return (false);
        }
        if (!getRequiredEntryId().equals(rhs.getRequiredEntryId())) {
            return (false);
        }
        return (true);
    } else if (obj instanceof CFAccHPKey) {
        CFAccHPKey rhs = (CFAccHPKey) obj;
        {
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        return (true);
    } else if (obj instanceof CFAccAccountEntryPKey) {
        CFAccAccountEntryPKey rhs = (CFAccAccountEntryPKey) obj;
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredAccountId() != rhs.getRequiredAccountId()) {
            return (false);
        }
        if (!getRequiredEntryId().equals(rhs.getRequiredEntryId())) {
            return (false);
        }
        return (true);
    } else if (obj instanceof CFAccAccountEntryHBuff) {
        CFAccAccountEntryHBuff rhs = (CFAccAccountEntryHBuff) obj;
        {
            long lhsClusterId = getAuditClusterId();
            long rhsClusterId = rhs.getAuditClusterId();
            if (lhsClusterId != rhsClusterId) {
                return (false);
            }
        }
        {
            Calendar lhsAuditStamp = getAuditStamp();
            Calendar rhsAuditStamp = rhs.getAuditStamp();
            if (lhsAuditStamp != null) {
                if (rhsAuditStamp != null) {
                    if (!lhsAuditStamp.equals(rhsAuditStamp)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        {
            short lhsActionId = getAuditActionId();
            short rhsActionId = rhs.getAuditActionId();
            if (lhsActionId != rhsActionId) {
                return (false);
            }
        }
        {
            int lhsRevision = getRequiredRevision();
            int rhsRevision = rhs.getRequiredRevision();
            if (lhsRevision != rhsRevision) {
                return (false);
            }
        }
        {
            UUID lhsAuditSessionId = getAuditSessionId();
            UUID rhsAuditSessionId = rhs.getAuditSessionId();
            if (lhsAuditSessionId != null) {
                if (rhsAuditSessionId != null) {
                    if (!lhsAuditSessionId.equals(rhsAuditSessionId)) {
                        return (false);
                    }
                } else {
                    return (false);
                }
            } else {
                return (false);
            }
        }
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredAccountId() != rhs.getRequiredAccountId()) {
            return (false);
        }
        if (!getRequiredEntryId().equals(rhs.getRequiredEntryId())) {
            return (false);
        }
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredAccountId() != rhs.getRequiredAccountId()) {
            return (false);
        }
        if (!getRequiredEntryId().equals(rhs.getRequiredEntryId())) {
            return (false);
        }
        return (true);
    } else if (obj instanceof CFAccAccountEntryBuff) {
        CFAccAccountEntryBuff rhs = (CFAccAccountEntryBuff) obj;
        if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
            return (false);
        }
        if (getRequiredAccountId() != rhs.getRequiredAccountId()) {
            return (false);
        }
        if (!getRequiredEntryId().equals(rhs.getRequiredEntryId())) {
            return (false);
        }
        return (true);
    } else {
        return (false);
    }
}

From source file:gov.utah.dts.sdc.actions.CommercialStudentCreateAction.java

private boolean isValidCompletionDate(Date date1) {

    Calendar today = Calendar.getInstance();
    Calendar date1Cal = Calendar.getInstance();
    date1Cal.setTime(date1);//from w ww .  ja  va 2 s.  c om

    // set hour, minute, and secod to 0
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);
    date1Cal.set(Calendar.HOUR_OF_DAY, 0);
    date1Cal.set(Calendar.MINUTE, 0);
    date1Cal.set(Calendar.SECOND, 0);
    date1Cal.set(Calendar.MILLISECOND, 0);

    if (date1Cal.before(today) || date1Cal.equals(today)) {
        return true;
    }

    return false;
}

From source file:org.onehippo.repository.bootstrap.InitializationProcessorTest.java

@Test
public void testPlainContentResourceInitialization() throws Exception {
    item.setProperty(HIPPO_CONTENTRESOURCE, getClass().getResource("/bootstrap/foo.xml").toString());
    item.setProperty(HIPPO_CONTENTROOT, "/test");
    session.save();//from   w  w  w  .  j  a  v  a 2 s  .  c o m
    List<PostStartupTask> tasks = process();
    assertEquals("There should be no post-startup tasks", 0, tasks.size());

    assertTrue(test.hasNode("foo"));
    Node foo = test.getNode("foo");
    assertTrue(foo.hasProperty("jcr:created"));
    final Calendar created = foo.getProperty("jcr:created").getDate();

    // test reload
    item.setProperty(HIPPO_RELOADONSTARTUP, true);
    item.setProperty(HIPPO_CONTEXTPATHS, new String[] { "/test/foo" });
    item.setProperty(HIPPO_STATUS, "pending");
    session.save();
    tasks = process();
    assertEquals("There should be no post-startup tasks", 0, tasks.size());

    assertTrue(test.hasNode("foo"));
    foo = test.getNode("foo");
    assertTrue(foo.hasProperty("jcr:created"));
    assertFalse(created.equals(foo.getProperty("jcr:created").getDate()));
}

From source file:org.kuali.kfs.module.tem.service.impl.PerDiemServiceImpl.java

/**
 * Determines if://from w  ww. ja v  a2s .  com
 * <ul>
 * <li>A current mileage rate for the KFS-TEM / Document / PER_DIEM_MILEAGE_RATE_EXPENSE_TYPE_CODE is available; if it is not, then per diem cannot be created
 * </ul>
 * @param form the form with the document on it, which may help in making such a decision
 */
@Override
public boolean isMileageRateAvailableForAllPerDiem(TravelDocument doc) {
    final String defaultPerDiemMileageRate = getDefaultPerDiemMileageRateExpenseType();
    if (StringUtils.isBlank(defaultPerDiemMileageRate)) {
        return false;
    }
    if (StringUtils.isBlank(doc.getTripTypeCode()) || doc.getTripBegin() == null || doc.getTripEnd() == null) {
        return true; // we can't create per diem when trip begin or end are blank anyhow - but we shouldn't get the error
    }
    // now we need to loop through each day from begin date to end date to see if there is a validate mileage rate record for it
    Calendar currDay = Calendar.getInstance();
    currDay.setTime(KfsDateUtils.clearTimeFields(doc.getTripBegin()));
    Calendar lastDay = Calendar.getInstance();
    lastDay.setTime(KfsDateUtils.clearTimeFields(doc.getTripEnd()));

    while (currDay.before(lastDay) || currDay.equals(lastDay)) {
        java.sql.Date effectiveDay = doc
                .getEffectiveDateForPerDiem(new java.sql.Timestamp(currDay.getTimeInMillis()));
        final MileageRate currDayMileageRate = getMileageRateService()
                .findMileageRateByExpenseTypeCodeAndDate(defaultPerDiemMileageRate, effectiveDay);
        if (currDayMileageRate == null) {
            return false;
        }
        currDay.add(Calendar.DATE, 1);
    }
    // we're good
    return true;
}

From source file:org.simbasecurity.core.saml.SAMLResponseHandlerImpl.java

/**
 * Verifies that the document is still valid according Conditions Element.
 *
 * @return true if still valid/*from  ww w. ja  v a2  s.  c  om*/
 */
private boolean validateTimestamps() {
    NodeList timestampNodes = document.getElementsByTagNameNS("*", "Conditions");
    if (timestampNodes.getLength() != 0) {
        for (int i = 0; i < timestampNodes.getLength(); i++) {
            NamedNodeMap attrName = timestampNodes.item(i).getAttributes();
            Node nbAttribute = attrName.getNamedItem("NotBefore");
            Node naAttribute = attrName.getNamedItem("NotOnOrAfter");
            Calendar now = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            log.debug("now :" + now.get(Calendar.HOUR_OF_DAY) + ":" + now.get(Calendar.MINUTE) + ":"
                    + now.get(Calendar.SECOND));
            // validate NotOnOrAfter using UTC
            if (naAttribute != null) {
                final Calendar notOnOrAfterDate = javax.xml.bind.DatatypeConverter
                        .parseDateTime(naAttribute.getNodeValue());
                log.debug("notOnOrAfterDate :" + notOnOrAfterDate.get(Calendar.HOUR_OF_DAY) + ":"
                        + notOnOrAfterDate.get(Calendar.MINUTE) + ":" + notOnOrAfterDate.get(Calendar.SECOND));
                if (now.equals(notOnOrAfterDate) || now.after(notOnOrAfterDate)) {
                    return false;
                }
            }
            // validate NotBefore using UTC
            if (nbAttribute != null) {
                final Calendar notBeforeDate = javax.xml.bind.DatatypeConverter
                        .parseDateTime(nbAttribute.getNodeValue());
                log.debug("notBeforeDate :" + notBeforeDate.get(Calendar.HOUR_OF_DAY) + ":"
                        + notBeforeDate.get(Calendar.MINUTE) + ":" + notBeforeDate.get(Calendar.SECOND));
                if (now.before(notBeforeDate)) {
                    return false;
                }
            }
        }
    }
    return true;
}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.util.DateComparator.java

/**
 * Return <code>true</code> if left operand is equal to right operand, or if any of the operand is null, <code>false</code> otherwise
 *
 *
 * @param leftOperandValue the <code>Calendar</code> value for the left operand
 * @param rightOperandValue the <code>Calendar</code> value for the right operand
 * @param leastPrecision the least precision of the two operands
 * @return <code>true</code> if left operand is equal to right operand, or if any of the operand is null, <code>false</code> otherwise
 *//*from  www .j av  a 2 s. c  om*/
private boolean isEqual(final Calendar leftOperandValue, final Calendar rightOperandValue,
        final String leastPrecision) {
    if (leftOperandValue == null || rightOperandValue == null) {
        return true;
    } else {

        if (PRECISION_YEAR.equals(leastPrecision)) {
            // compare only year, true if the same
            return leftOperandValue.get(Calendar.YEAR) == rightOperandValue.get(Calendar.YEAR);

        } else if (PRECISION_MONTH.equals(leastPrecision)) {
            // compare only month and year, true if the same
            return leftOperandValue.get(Calendar.YEAR) == rightOperandValue.get(Calendar.YEAR)
                    && leftOperandValue.get(Calendar.MONTH) == rightOperandValue.get(Calendar.MONTH);
        } else {
            return leftOperandValue.equals(rightOperandValue);
        }
    }
}

From source file:gov.utah.dts.sdc.actions.CommercialStudentCreateAction.java

/**
 * Checks if date1 is in the between date2 and today date inclusively.
 * @param date1//from   w w w  .  j  av  a2s .c  om
 * @param date2
 * @return
 */
private boolean isValidCompletionDate(Date date1, Date date2) {

    Calendar today = Calendar.getInstance();
    Calendar date1Cal = Calendar.getInstance();
    date1Cal.setTime(date1);
    Calendar date2Cal = Calendar.getInstance();
    date2Cal.setTime(date2);

    // set hour, minute, and secod to 0
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);
    date1Cal.set(Calendar.HOUR_OF_DAY, 0);
    date1Cal.set(Calendar.MINUTE, 0);
    date1Cal.set(Calendar.SECOND, 0);
    date1Cal.set(Calendar.MILLISECOND, 0);
    date2Cal.set(Calendar.HOUR_OF_DAY, 0);
    date2Cal.set(Calendar.MINUTE, 0);
    date2Cal.set(Calendar.SECOND, 0);

    if (date2Cal.after(today))
        return false;

    if (date1Cal.equals(date2Cal) || date1Cal.equals(today))
        return true;

    if (date1Cal.before(today) && date1Cal.after(date2Cal))
        return true;

    return false;
}

From source file:nl.strohalm.cyclos.services.accounts.AccountServiceImpl.java

@Override
public BigDecimal getExclusiveBalance(final AccountDateDTO params) {
    Account account = getAccount(params);
    Calendar date = params.getDate();

    // Get the last closed balance before the given date
    ClosedAccountBalance closedBalance = closedAccountBalanceDao.get(account, date);
    BigDecimal balance = closedBalance == null ? BigDecimal.ZERO : closedBalance.getBalance();

    if (date == null || closedBalance == null || !date.equals(closedBalance.getDate())) {
        Calendar beginDate = (closedBalance == null) ? null : closedBalance.getDate();
        Period balanceDiffPeriod = Period.between(beginDate, date).useTime();
        balanceDiffPeriod.setInclusiveEnd(false);
        BigDecimal diff = transferDao.balanceDiff(account, balanceDiffPeriod);
        balance = balance.add(diff);/*  w w w.j av  a 2 s.  c  o  m*/
    }
    return balance;
}

From source file:com.southernstorm.tvguide.TvChannelCache.java

private void reportRequestResult(RequestInfo info) {
    for (TvNetworkListener listener : networkListeners) {
        if (info.date == null)
            continue;
        else if (info.success)
            listener.dataAvailable(info.channel, info.date, currentRequestPrimaryDate);
        else//from w w w . j a v a2s.  c om
            listener.requestFailed(info.channel, info.date, currentRequestPrimaryDate);
    }
    if (info.isChannelIconFetch() && info.success) {
        info.channel.setIconFile(info.dataFile.getPath());
        for (TvChannelChangedListener channelListener : channelListeners)
            channelListener.channelsChanged();
    } else if (info.isChannelListFetch()) {
        // Main channel list has been fetched - reload the channels.
        mainListFetching = false;
        if (info.success) {
            Calendar lastmod = channelDataLastModified(null, null);
            if (lastmod != null && mainListLastMod != null && lastmod.equals(mainListLastMod))
                mainListUnchanged = true; // Break infinite loop: don't try to fetch again.
            loadChannels();
        }
    }
}