Example usage for org.apache.commons.lang3.time DateUtils isSameDay

List of usage examples for org.apache.commons.lang3.time DateUtils isSameDay

Introduction

In this page you can find the example usage for org.apache.commons.lang3.time DateUtils isSameDay.

Prototype

public static boolean isSameDay(final Calendar cal1, final Calendar cal2) 

Source Link

Document

Checks if two calendar objects are on the same day ignoring time.

28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.

Usage

From source file:net.audumla.astronomy.algorithims.EllipticalObject.java

@Override
public TransitDetails getTransitDetails(Date date, Geolocation location, double altitude) {
    // to make sure that the dates for rise and set are for the correct day this code checks the resultant rise and set days.
    // as all times are calculated using UTC there is a chance that they may not be for the requested local day.
    // I have attempted to adjust the passed in time using the local time offset however this has not worked, so a
    // brute force method has been applied to recalculate using either the next or previous day.
    // this method has also run into problems when adjusting by +/- 24 hours. It appears that borderline cases may actually
    // cause the calculation to jump another whole day and therefore result in a calculation that is another full day in the
    // desired direction. Currently it appears that using +/- 23 hours will fix this as the borderline cases are as result
    // of the few seconds/minutes difference in rise times each day. This needs to be monitored however and more thorough testing applied.
    JulianTransitDetails details = calcTransitDetails(date, location, altitude);
    JulianTransitDetails detailsAdj = null;
    if (!DateUtils.isSameDay(date, details.getRiseTime())) {
        detailsAdj = calcTransitDetails(DateUtils.addHours(date, date.after(date) ? 23 : -23), location,
                altitude);/*from   w  ww  .  ja  v a 2  s  .com*/
        details.setRise((detailsAdj.getJulianRise().julian() - details.getReferenceTime().julian()) * 24);
    }

    if (!DateUtils.isSameDay(date, details.getSetTime())) {
        detailsAdj = calcTransitDetails(DateUtils.addHours(date, date.after(date) ? 23 : -23), location,
                altitude);
        details.setSet((detailsAdj.getJulianSet().julian() - details.getReferenceTime().julian()) * 24);
    }

    assert DateUtils.isSameDay(details.getRiseTime(), details.getSetTime());
    return details;
}

From source file:com.webbfontaine.valuewebb.model.TtLog.java

public Boolean dateTitleRequired() {
    Date today = new Date();
    int i = ttGen.getLogs().indexOf(this); //list is ordered by Date (ascending)
    return (i == 0 && !DateUtils.isSameDay(date, today))
            || (i > 0 && !DateUtils.isSameDay(ttGen.getLogs().get(i - 1).getDate(), date));
}

From source file:com.inkubator.common.util.DateTimeUtil.java

/**
 * Checking from two date type, will return true if the date have the same
 * value, same date not same time./*from  ww  w. ja v  a 2 s  .co  m*/
 *
 * @return Boolean
 * @param date1 Date reference
 * @param date2 Date reference
 */
public static Boolean isSameDateWithTimeIgnore(Date date1, Date date2) {
    return DateUtils.isSameDay(date1, date2);
}

From source file:com.premiumminds.billy.france.services.builders.impl.FRManualInvoiceEntryBuilderImpl.java

@Override
protected void validateValues() throws BillyValidationException {
    GenericInvoiceEntryEntity e = this.getTypeInstance();
    for (Tax t : e.getProduct().getTaxes()) {
        if (this.daoContext.isSubContext(t.getContext(), this.context)) {
            Date taxDate = e.getTaxPointDate() == null ? new Date() : e.getTaxPointDate();
            if (DateUtils.isSameDay(t.getValidTo(), taxDate) || t.getValidTo().after(taxDate)) {
                e.getTaxes().add(t);/*from  w  ww  .ja  va 2s.c  o m*/
            }
        }
    }
    if (e.getTaxes().isEmpty()) {
        throw new ValidationException(
                GenericInvoiceEntryBuilderImpl.LOCALIZER.getString("exception.invalid_taxes"));
    }
}

From source file:com.esofthead.mycollab.mobile.module.project.view.ProjectActivityStreamListDisplay.java

@Override
protected void renderRows() {
    int i = 0;/*  w  w  w  .  j a va  2 s.  c om*/
    Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();
    for (final ProjectActivityStream item : currentListData) {
        if (!DateUtils.isSameDay(item.getCreatedtime(), currentDate)) {
            Label dateLbl = new Label(AppContext.formatDate(item.getCreatedtime()));
            dateLbl.setStyleName("activity-date");
            listContainer.addComponent(dateLbl);
            currentDate = item.getCreatedtime();
        }
        final Component row = getRowDisplayHandler().generateRow(item, i);
        listContainer.addComponent(row);
        i++;
    }
}

From source file:com.mycollab.mobile.module.project.view.ProjectActivityStreamListDisplay.java

@Override
protected void renderRows() {
    int i = 0;//w w w.  ja  v  a 2  s  . c  om
    Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();
    for (final ProjectActivityStream item : currentListData) {
        if (!DateUtils.isSameDay(item.getCreatedtime(), currentDate)) {
            listContainer
                    .addComponent(FormSectionBuilder.build(UserUIContext.formatDate(item.getCreatedtime())));
            currentDate = item.getCreatedtime();
        }
        final Component row = getRowDisplayHandler().generateRow(this, item, i);
        if (row != null) {
            listContainer.addComponent(row);
        }
        i++;
    }
}

From source file:de.tor.tribes.types.TimeSpan.java

public boolean isValidAtSpecificDay() {
    return !isValidAtEveryDay() && !isValidAtExactTime()
            && DateUtils.isSameDay(new Date(exactSpan.getMinimum()), new Date(exactSpan.getMaximum()));
}

From source file:eu.ggnet.dwoss.redtape.entity.util.DocumentEquals.java

/**
 * Checks if two documents are not equal returning a string containing the message what is not equal or null.
 *
 * @param d1 Document one// www . j  ava  2 s  .  com
 * @param d2 Document two
 * @return null if equal or a string describing the difference.
 */
public String equalsMessage(Document d1, Document d2) {
    if (d1 == null)
        return "d1 is null";
    if (d2 == null)
        return "d2 is null";
    if (properties.contains(SETTLEMENTS))
        if (!Objects.equals(d1.getSettlements(), d2.getSettlements()))
            return "Settlements are not equal, d1=" + d1.getSettlements() + ", d2=" + d2.getSettlements();
    if (properties.contains(ACTUAL)) {
        if (d1.getActual() == null && d2.getActual() != null)
            return "Actual is not equal, d1=" + d1.getActual() + ", d2=" + d2.getActual();
        if (d1.getActual() != null && d2.getActual() == null)
            return "Actual is not equal, d1=" + d1.getActual() + ", d2=" + d2.getActual();
        if (!DateUtils.isSameDay(d1.getActual(), d2.getActual()))
            return "Actual is not equal, d1=" + d1.getActual() + ", d2=" + d2.getActual();
    }
    if (properties.contains(IDENTIFIER))
        if (!Objects.equals(d1.getIdentifier(), d2.getIdentifier()))
            return "Identifier is not equal, d1=" + d1.getIdentifier() + ", d2=" + d2.getIdentifier();
    if (properties.contains(CONDITIONS))
        if (!Objects.equals(d1.getConditions(), d2.getConditions()))
            return "Conditions are not equal, d1=" + d1.getConditions() + ", d2=" + d2.getConditions();
    if (properties.contains(TYPE))
        if (d1.getType() != d2.getType())
            return "Type is not equal, d1=" + d1.getType() + ", d2=" + d2.getType();
    if (properties.contains(DOSSIER))
        if (!d1.getDossier().equals(d2.getDossier()))
            return "Dossier is not equal, d1=" + d1.getDossier() + ", d2=" + d2.getDossier();
    if (properties.contains(ID))
        if (d1.getId() != d2.getId())
            return "Id is not equal, d1=" + d1.getId() + ", d2=" + d2.getId();
    if (properties.contains(ACTIVE))
        if (d1.isActive() != d2.isActive())
            return "Active is not equal, d1=" + d1.isActive() + ", d2=" + d2.isActive();
    if (properties.contains(HISTORY))
        if (!Objects.equals(d1.getHistory(), d2.getHistory()))
            return "History is not equal, d1=" + d1.getHistory() + ", d2=" + d2.getHistory();
    if (properties.contains(PREDECESSOR))
        if (!Objects.equals(d1.getPredecessor(), d2.getPredecessor()))
            return "Predecessor is not equal, d1=" + d1.getPredecessor() + ", d2=" + d2.getPredecessor();
    if (properties.contains(FLAGS))
        if (!Objects.equals(d1.getFlags(), d2.getFlags()))
            return "Flags is not equal, d1=" + d1.getFlags() + ", d2=" + d2.getFlags();
    if (properties.contains(DIRECTIVE))
        if (d1.getDirective() != d2.getDirective())
            return "Directive is not equal, d1=" + d1.getDirective() + ", d2=" + d2.getDirective();
    if (properties.contains(INVOICE_ADDRESS))
        if (!Objects.equals(d1.getInvoiceAddress(), d2.getInvoiceAddress()))
            return "Invoiceaddress is not equal, d1=" + d1.getInvoiceAddress() + ", d2="
                    + d2.getInvoiceAddress();
    if (properties.contains(SHIPPING_ADDRESS))
        if (!Objects.equals(d1.getShippingAddress(), d2.getShippingAddress()))
            return "Shippingaddress is not equal, d1=" + d1.getShippingAddress() + ", d2="
                    + d2.getShippingAddress();
    if (properties.contains(CLOSED))
        if (d1.isClosed() != d2.isClosed())
            return "Closed is not equal, d1=" + d1.isClosed() + ", d2=" + d2.isClosed();
    if (positionTypes.size() == PositionType.values().length)
        if (d1.getPositions().size() != d2.getPositions().size())
            return "Positions.size is not equal, d1=" + d1.getPositions().size() + ", d2="
                    + d2.getPositions().size();
    if (positionTypes.size() == PositionType.values().length && positionOrder) {
        Iterator<Position> p1 = new TreeSet<>(d1.getPositions().values()).iterator();
        Iterator<Position> p2 = new TreeSet<>(d2.getPositions().values()).iterator();
        while (p1.hasNext()) {
            Position p1p = p1.next();
            Position p2p = p2.next();
            if (!p1p.equalsContent(p2p))
                return "Positions are not equal d1=" + p1p + ", d2=" + p2p;
        }
    } else {
        List<Position> d1Poss = new ArrayList<>();
        List<Position> d2Poss = new ArrayList<>();
        for (Position pos : d1.getPositions().values()) {
            if (positionTypes.contains(pos.getType()))
                d1Poss.add(pos);
        }
        for (Position pos : d2.getPositions().values()) {
            if (positionTypes.contains(pos.getType()))
                d2Poss.add(pos);
        }
        if (d1Poss.size() != d2Poss.size())
            return "Posistions subSiz is not equal d1=" + d1Poss.size() + ", d2=" + d2Poss.size()
                    + ", evaluating only types " + positionTypes;
        for (Position pos1 : d1Poss) {
            boolean existAndIsEqual = false;
            for (Position pos2 : d2Poss) {
                if (pos1.equalsContentWithoutId(pos2))
                    existAndIsEqual = true;
            }
            if (!existAndIsEqual)
                return "Subpositions are not equal d1=" + d1Poss + ", d2=" + d2Poss;
        }
    }
    return null;
}

From source file:com.premiumminds.billy.france.services.builders.impl.FRManualEntryBuilderImpl.java

@Override
protected void validateValues() throws ValidationException {
    GenericInvoiceEntryEntity e = this.getTypeInstance();

    for (Tax t : e.getProduct().getTaxes()) {
        if (this.daoContext.isSubContext(t.getContext(), this.context)) {
            Date taxDate = e.getTaxPointDate() == null ? new Date() : e.getTaxPointDate();
            if (DateUtils.isSameDay(t.getValidTo(), taxDate) || t.getValidTo().after(taxDate)) {
                e.getTaxes().add(t);/*w w  w.java 2s. co m*/
            }
        }
    }
}

From source file:co.com.soinsoftware.hotelero.view.JFRoomDetail.java

private void showButtonsByRoomStatus(final Room room, final RoomStatus roomStatus) {
    if (roomStatus.equals(this.roomStatusBooked)) {
        final Date currentDate = new Date();
        if (DateUtils.isSameDay(currentDate, this.jdcInitialDate.getDate())
                && this.validateRoomIsAvailable(room)) {
            this.jbtCheckIn.setVisible(true);
        } else {//from w w  w . j a  v a 2  s.  c om
            this.jbtCheckIn.setVisible(false);
        }
        this.jbtDelete.setVisible(true);
    } else {
        this.jbtCheckIn.setVisible(false);
        this.jbtDelete.setVisible(false);
    }
}