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

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

Introduction

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

Prototype

public static boolean isSameDay(Calendar cal1, 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:org.jasig.schedassist.model.AvailableBlockBuilderTest.java

/**
 * Test that highlights the problem when a customer specifies a start/end range
 * for blocks and a meeting duration that leaves a remainder.
 * //from  ww w.  ja  va  2 s.c om
 * @throws ParseException 
 * @throws InputFormatException 
 */
@Test
public void testDurationLeavesRemainder() throws InputFormatException, ParseException {
    SimpleDateFormat dateFormat = CommonDateOperations.getDateFormat();
    SortedSet<AvailableBlock> blocks = AvailableBlockBuilder.createBlocks("9:03 AM", "3:19 PM", "MWF",
            dateFormat.parse("20100830"), dateFormat.parse("20100903"));
    Assert.assertEquals(3, blocks.size());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0903"),
            blocks.first().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-1519"),
            blocks.first().getEndTime());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-0903"),
            blocks.last().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-1519"),
            blocks.last().getEndTime());

    SortedSet<AvailableBlock> expanded = AvailableBlockBuilder.expand(blocks, 17);
    AvailableBlock last = null;

    long millisIn17Minutes = 1020000L;
    for (AvailableBlock e : expanded) {
        if (last != null) {
            if (DateUtils.isSameDay(e.getStartTime(), last.getStartTime())) {
                Assert.assertEquals(last.getEndTime(), e.getStartTime());
                Assert.assertEquals(e.getEndTime().getTime() - last.getEndTime().getTime(), millisIn17Minutes);
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(e.getStartTime());
                Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(3, cal.get(Calendar.MINUTE));

                cal.setTime(e.getEndTime());
                Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(20, cal.get(Calendar.MINUTE));

                // double check yesterday's endpoint
                cal.setTime(last.getStartTime());
                Assert.assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(0, cal.get(Calendar.MINUTE));

                cal.setTime(last.getEndTime());
                Assert.assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
                Assert.assertEquals(17, cal.get(Calendar.MINUTE));
            }
        } else {
            // first block in the series
            Calendar cal = Calendar.getInstance();
            cal.setTime(e.getStartTime());
            Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
            Assert.assertEquals(3, cal.get(Calendar.MINUTE));

            cal.setTime(e.getEndTime());
            Assert.assertEquals(9, cal.get(Calendar.HOUR_OF_DAY));
            Assert.assertEquals(20, cal.get(Calendar.MINUTE));
        }
        last = e;
    }

    Assert.assertEquals(66, expanded.size());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0903"),
            expanded.first().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100830-0920"),
            expanded.first().getEndTime());

    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-1500"),
            expanded.last().getStartTime());
    Assert.assertEquals(CommonDateOperations.getDateTimeFormat().parse("20100903-1517"),
            expanded.last().getEndTime());

}

From source file:org.kuali.kfs.fp.businessobject.CheckBase.java

/**
 * @see org.kuali.kfs.fp.businessobject.Check#isLike(org.kuali.kfs.fp.businessobject.Check)
 *///w  w  w  .ja va2  s  .c o  m
@Override
public boolean isLike(Check other) {
    boolean like = false;

    if (StringUtils.equals(checkNumber, other.getCheckNumber())) {
        if (StringUtils.equals(description, other.getDescription())) {
            if (StringUtils.equals(financialDocumentTypeCode, other.getFinancialDocumentTypeCode())
                    && StringUtils.equals(cashieringStatus, other.getCashieringStatus())) {
                if (StringUtils.equals(documentNumber, other.getDocumentNumber())) {
                    if (ObjectUtils.nullSafeEquals(sequenceId, other.getSequenceId())) {
                        if (ObjectUtils.nullSafeEquals(financialDocumentDepositLineNumber,
                                other.getFinancialDocumentDepositLineNumber())) {

                            if (DateUtils.isSameDay(checkDate, other.getCheckDate())) {
                                if ((amount != null) && amount.equals(other.getAmount())) {
                                    like = true;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return like;
}

From source file:org.kuali.kfs.module.cam.document.service.AssetTransferServiceTest.java

@ConfigureContext(session = khuntley, shouldCommitTransactions = false)
public void testSaveApprovedChanges() throws Exception {
    AssetTransferDocument document = buildTransferDocument(AssetTransferFixture.ACTIVE_CAPITAL_ASSET.newAsset(),
            true);/*from ww  w  .  j  a v  a  2  s .com*/
    this.assetTransferService.saveApprovedChanges(document);
    BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
    Asset asset = document.getAsset();
    asset = (Asset) boService.retrieve(asset);
    asset.refreshReferenceObject(CamsPropertyConstants.Asset.ASSET_PAYMENTS);
    assertNotNull(asset);
    assertEquals(document.getOrganizationOwnerChartOfAccountsCode(),
            asset.getOrganizationOwnerChartOfAccountsCode());
    assertEquals(document.getOrganizationOwnerAccountNumber(), asset.getOrganizationOwnerAccountNumber());
    assertEquals(document.getCampusCode(), asset.getCampusCode());
    assertEquals(document.getBuildingCode(), asset.getBuildingCode());
    assertEquals(document.getBuildingRoomNumber(), asset.getBuildingRoomNumber());
    assertEquals(document.getBuildingSubRoomNumber(), asset.getBuildingSubRoomNumber());
    assertTrue(DateUtils.isSameDay(new java.util.Date(), asset.getLastInventoryDate()));
    List<AssetPayment> assetPayments = asset.getAssetPayments();
    // sort the payment
    Collections.sort(assetPayments, new Comparator<AssetPayment>() {
        @Override
        public int compare(AssetPayment o1, AssetPayment o2) {
            return o1.getPaymentSequenceNumber().compareTo(o2.getPaymentSequenceNumber());
        }
    });
    assertEquals(6, assetPayments.size());
    // Asset original payment 1
    AssetPayment testDataPayment = AssetTransferFixture.PAYMENT1_WITH_OFFSET.newAssetPayment();
    AssetPayment assetPayment1 = assetPayments.get(0);
    assertOriginalPayment(testDataPayment, assetPayment1);

    // Assert original payment 2
    testDataPayment = AssetTransferFixture.PAYMENT2_WITH_OFFSET.newAssetPayment();
    AssetPayment assetPayment2 = assetPayments.get(1);
    assertOriginalPayment(testDataPayment, assetPayment2);

    // Assert offset payment 1
    testDataPayment = AssetTransferFixture.PAYMENT1_WITH_OFFSET.newAssetPayment();
    AssetPayment offsetPayment1 = assetPayments.get(2);
    assertOffsetPayment(testDataPayment, offsetPayment1);

    // Assert offset payment 2
    testDataPayment = AssetTransferFixture.PAYMENT2_WITH_OFFSET.newAssetPayment();
    AssetPayment offsetPayment2 = assetPayments.get(3);
    assertOffsetPayment(testDataPayment, offsetPayment2);

    // Assert new payment 1
    testDataPayment = AssetTransferFixture.PAYMENT1_WITH_OFFSET.newAssetPayment();
    AssetPayment newPayment1 = assetPayments.get(4);
    assertNewPayment(document, testDataPayment, newPayment1);

    // Assert new payment 2
    testDataPayment = AssetTransferFixture.PAYMENT2_WITH_OFFSET.newAssetPayment();
    AssetPayment newPayment2 = assetPayments.get(5);
    assertNewPayment(document, testDataPayment, newPayment2);
}

From source file:org.kuali.kfs.module.cam.document.service.AssetTransferServiceTest.java

@ConfigureContext(session = khuntley, shouldCommitTransactions = false)
public void testSaveApprovedChanges_Offcampus() throws Exception {
    AssetTransferDocument document = buildTransferDocument(AssetTransferFixture.ACTIVE_CAPITAL_ASSET.newAsset(),
            true);//from w ww.j av  a 2 s .c  om
    document.setOffCampusAddress("4700 S HAGADORN");
    document.setOffCampusCityName("E LANSING");
    document.setOffCampusStateCode("MI");
    document.setOffCampusZipCode("48823");

    // clear fields that conflict with off-campus data
    document.setCampusCode(null);
    document.setBuildingCode(null);
    document.setBuildingRoomNumber(null);
    document.setBuildingSubRoomNumber(null);

    this.assetTransferService.saveApprovedChanges(document);
    BusinessObjectService boService = SpringContext.getBean(BusinessObjectService.class);
    Asset asset = document.getAsset();
    asset = (Asset) boService.retrieve(asset);
    asset.refreshReferenceObject(CamsPropertyConstants.Asset.ASSET_LOCATIONS);
    SpringContext.getBean(AssetLocationService.class).setOffCampusLocation(asset);
    assertNotNull(asset);
    assertEquals(document.getOrganizationOwnerChartOfAccountsCode(),
            asset.getOrganizationOwnerChartOfAccountsCode());
    assertEquals(document.getOrganizationOwnerAccountNumber(), asset.getOrganizationOwnerAccountNumber());
    assertEquals(document.getCampusCode(), asset.getCampusCode());
    assertTrue(DateUtils.isSameDay(new java.util.Date(), asset.getLastInventoryDate()));
    AssetLocation offCampusLocation = asset.getOffCampusLocation();
    assertNotNull(offCampusLocation);
    assertEquals("4700 S HAGADORN", offCampusLocation.getAssetLocationStreetAddress());
    assertEquals("E LANSING", offCampusLocation.getAssetLocationCityName());
    assertEquals("MI", offCampusLocation.getAssetLocationStateCode());
    assertEquals("48823", offCampusLocation.getAssetLocationZipCode());
}

From source file:org.kuali.kfs.module.endow.batch.service.impl.UpdateCorpusServiceImpl.java

/**
 * Determines if the current date is the same as the first day of the fiscal year
 * /*from  w w w  .jav a2  s .  c o m*/
 * @param currentDate
 * @return
 */
protected boolean isFirstDayOfFiscalYear() {
    Date firstDateOfFiscalYear = (Date) universityDateService
            .getFirstDateOfFiscalYear(universityDateService.getCurrentFiscalYear());

    return DateUtils.isSameDay(currentDate, firstDateOfFiscalYear);
}

From source file:org.kuali.kfs.module.endow.batch.service.impl.UpdateCorpusServiceImpl.java

/**
 * Determines if the current date is the same as the last day of the fiscal year
 * /*from  w  w  w  .  java2s . c om*/
 * @return
 */
protected boolean isLastDayOfFiscalYear() {
    Date lastDateOfFiscalYear = (Date) kemService.getFiscalYearEndDayAndMonth();

    return DateUtils.isSameDay(currentDate, lastDateOfFiscalYear);
}

From source file:org.kuali.kpme.tklm.leave.batch.LeaveCalendarDelinquencyJob.java

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    Set<String> principalIds = new HashSet<String>();

    DateTime asOfDate = new LocalDate().toDateTimeAtStartOfDay();
    List<CalendarEntry> calendarEntries = getCalendarEntryService()
            .getCurrentCalendarEntriesNeedsScheduled(getCalendarEntriesPollingWindow(), asOfDate);

    for (CalendarEntry calendarEntry : calendarEntries) {
        String hrCalendarId = calendarEntry.getHrCalendarId();
        DateTime currentBeginDate = calendarEntry.getBeginPeriodFullDateTime();

        if (currentBeginDate.isBefore(asOfDate)
                || DateUtils.isSameDay(currentBeginDate.toDate(), asOfDate.toDate())) {
            CalendarEntry previousCalendarEntry = getCalendarEntryService()
                    .getPreviousCalendarEntryByCalendarId(hrCalendarId, calendarEntry);

            if (previousCalendarEntry != null) {
                String calendarName = previousCalendarEntry.getCalendarName();
                LocalDate previousBeginDate = previousCalendarEntry.getBeginPeriodFullDateTime().toLocalDate();
                List<PrincipalHRAttributes> principalHRAttributes = getPrincipalHRAttributesService()
                        .getActiveEmployeesForLeaveCalendar(calendarName, previousBeginDate);

                for (PrincipalHRAttributes principalHRAttribute : principalHRAttributes) {
                    String principalId = principalHRAttribute.getPrincipalId();

                    if (!principalIds.contains(principalId)) {
                        List<LeaveCalendarDocumentHeader> leaveCalendarDocumentHeaders = getLeaveCalendarDocumentHeaderService()
                                .getSubmissionDelinquentDocumentHeaders(principalId, currentBeginDate);

                        if (!leaveCalendarDocumentHeaders.isEmpty()) {
                            principalIds.add(principalId);
                        }//from  ww  w .  j a v a2 s  .  c o m
                    }
                }
            }
        }
    }

    for (String principalId : principalIds) {
        String subject = "Delinquent Leave Calendar Reminder";
        StringBuilder message = new StringBuilder();
        message.append("You currently have one or more DELINQUENT Leave Calendars.");
        message.append(SystemUtils.LINE_SEPARATOR);
        message.append(SystemUtils.LINE_SEPARATOR);
        message.append(
                "Please review/enter your time-off for any prior unapproved months and submit your calendar(s).");

        getKpmeNotificationService().sendNotification(subject, message.toString(), principalId);
    }
}

From source file:org.kuali.kpme.tklm.leave.block.service.LeaveBlockServiceImpl.java

@Override
public List<LeaveBlock> addLeaveBlocks(DateTime beginDate, DateTime endDate, CalendarEntry ce,
        String selectedEarnCode, BigDecimal hours, String description, Assignment selectedAssignment,
        String spanningWeeks, String leaveBlockType, String principalId) {

    List<LeaveBlockBo> newlyAddedLeaveBlocks = new ArrayList<LeaveBlockBo>();
    DateTimeZone timezone = HrServiceLocator.getTimezoneService().getUserTimezoneWithFallback();
    DateTime calBeginDateTime = beginDate;
    DateTime calEndDateTime = endDate;/*from   w ww . jav  a  2s.  c om*/

    if (ce != null) {
        calBeginDateTime = ce.getBeginPeriodLocalDateTime().toDateTime();
        calEndDateTime = ce.getEndPeriodLocalDateTime().toDateTime();
    } else {
        LOG.error("Calendar Entry parameter is null.");
        return ModelObjectUtils.transform(newlyAddedLeaveBlocks, toLeaveBlock);
        //          throw new RuntimeException("Calendar Entry parameter is null.");
    }

    Interval calendarInterval = new Interval(calBeginDateTime, calEndDateTime);

    // To create the correct interval by the given begin and end dates,
    // we need to plus one day on the end date to include that date
    List<Interval> leaveBlockIntervals = TKUtils.createDaySpan(beginDate.toLocalDate().toDateTimeAtStartOfDay(),
            endDate.toLocalDate().toDateTimeAtStartOfDay().plusDays(1), TKUtils.getSystemDateTimeZone());

    // need to use beginDate and endDate of the calendar to find all leaveBlocks since LeaveCalendarDocument Id is not always available
    List<LeaveBlockBo> currentLeaveBlocks = getLeaveBlockBos(principalId, calBeginDateTime.toLocalDate(),
            calEndDateTime.toLocalDate());

    // use the current calendar's begin and end date to figure out if this pay period has a leaveDocument
    LeaveCalendarDocumentHeader lcdh = LmServiceLocator.getLeaveCalendarDocumentHeaderService()
            .getDocumentHeader(principalId, ce.getBeginPeriodLocalDateTime().toDateTime(),
                    ce.getEndPeriodLocalDateTime().toDateTime());
    TimesheetDocumentHeader tsdh = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeader(
            principalId, ce.getBeginPeriodLocalDateTime().toDateTime(),
            ce.getEndPeriodLocalDateTime().toDateTime());
    String docId = lcdh == null ? (tsdh == null ? null : tsdh.getDocumentId()) : lcdh.getDocumentId();

    // TODO: need to integrate with the scheduled timeoff.
    Interval firstDay = null;
    DateTime currentDate = beginDate;

    EarnCode earnCodeObj = HrServiceLocator.getEarnCodeService().getEarnCode(selectedEarnCode,
            endDate.toLocalDate());
    for (Interval leaveBlockInt : leaveBlockIntervals) {
        if (calendarInterval.contains(leaveBlockInt)) {
            // KPME-1446 if "Include weekends" check box is checked, don't add Sat and Sun to the leaveblock list
            if (StringUtils.isEmpty(spanningWeeks)
                    && (leaveBlockInt.getStart().getDayOfWeek() == DateTimeConstants.SATURDAY
                            || leaveBlockInt.getStart().getDayOfWeek() == DateTimeConstants.SUNDAY)) {

                // do nothing
            } else {

                // Currently, we store the accrual category value in the leave code table, but store accrual category id in the leaveBlock.
                // That's why there is a two step server call to get the id. This might be changed in the future.

                CalendarEntry calendarEntry = HrServiceLocator.getCalendarEntryService()
                        .getCurrentCalendarEntryByCalendarId(ce.getHrCalendarId(),
                                new LocalDate().toDateTimeAtStartOfDay());
                DateTime leaveBlockDate = leaveBlockInt.getStart();
                String requestStatus = HrConstants.REQUEST_STATUS.USAGE;
                if (LmServiceLocator.getLeaveApprovalService().isActiveAssignmentFoundOnJobFlsaStatus(
                        principalId, HrConstants.FLSA_STATUS_NON_EXEMPT, true)) {
                    TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService()
                            .getDocumentHeaderForDate(principalId, leaveBlockDate);
                    if (tdh != null) {
                        if (DateUtils.isSameDay(leaveBlockDate.toDate(), tdh.getEndDate())
                                || leaveBlockDate.isAfter(tdh.getEndDateTime())) {
                            requestStatus = HrConstants.REQUEST_STATUS.PLANNED;
                        }
                    } else {
                        requestStatus = HrConstants.REQUEST_STATUS.PLANNED;
                    }
                } else {
                    if (DateUtils.isSameDay(leaveBlockDate.toDate(),
                            calendarEntry.getEndPeriodFullDateTime().toDate())
                            || leaveBlockDate.isAfter(calendarEntry.getEndPeriodFullDateTime())) {
                        requestStatus = HrConstants.REQUEST_STATUS.PLANNED;
                    }
                }

                if (earnCodeObj != null
                        && earnCodeObj.getRecordMethod().equals(HrConstants.RECORD_METHOD.TIME)) {
                    if (firstDay != null) {
                        if (!leaveBlockInt.contains(endDate)) {
                            currentDate = leaveBlockInt.getStart();
                        } else if ((leaveBlockInt.getStartMillis() - endDate.getMillis()) != 0) {

                            hours = TKUtils.getHoursBetween(leaveBlockInt.getStartMillis(),
                                    endDate.getMillis());
                            if (leaveBlockType.equalsIgnoreCase(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR)) {
                                hours = applyInflateMinHoursAndFactor(earnCodeObj, hours);
                            }
                            hours = negateHoursIfNecessary(leaveBlockType, hours);

                            LeaveBlockBo leaveBlock = buildLeaveBlock(leaveBlockInt.getStart().toLocalDate(),
                                    docId, principalId, selectedEarnCode, hours, description,
                                    earnCodeObj.getAccrualCategory(), selectedAssignment, requestStatus,
                                    leaveBlockType, leaveBlockInt.getStart(), endDate);

                            if (!currentLeaveBlocks.contains(leaveBlock)) {
                                newlyAddedLeaveBlocks.add(leaveBlock);
                                currentLeaveBlocks.add(leaveBlock);
                            }
                            break;
                        }
                    }
                    if (leaveBlockInt.contains(currentDate)) {

                        firstDay = leaveBlockInt;

                        if (leaveBlockInt.contains(endDate)
                                || (endDate.getMillis() == leaveBlockInt.getEnd().getMillis())) {

                            hours = TKUtils.getHoursBetween(currentDate.getMillis(), endDate.getMillis());
                            if (leaveBlockType.equalsIgnoreCase(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR)) {
                                hours = applyInflateMinHoursAndFactor(earnCodeObj, hours);
                            }
                            hours = negateHoursIfNecessary(leaveBlockType, hours);

                            LeaveBlockBo leaveBlock = buildLeaveBlock(leaveBlockInt.getStart().toLocalDate(),
                                    docId, principalId, selectedEarnCode, hours, description,
                                    earnCodeObj.getAccrualCategory(), selectedAssignment, requestStatus,
                                    leaveBlockType, currentDate, endDate);

                            if (!currentLeaveBlocks.contains(leaveBlock)) {
                                newlyAddedLeaveBlocks.add(leaveBlock);
                                currentLeaveBlocks.add(leaveBlock);
                            }

                            break;

                        } else {
                            // create a leave block that wraps the 24 hr day
                            hours = TKUtils.getHoursBetween(currentDate.getMillis(), firstDay.getEndMillis());
                            if (leaveBlockType.equalsIgnoreCase(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR)) {
                                hours = applyInflateMinHoursAndFactor(earnCodeObj, hours);
                            }
                            hours = negateHoursIfNecessary(leaveBlockType, hours);

                            LeaveBlockBo leaveBlock = buildLeaveBlock(leaveBlockInt.getStart().toLocalDate(),
                                    docId, principalId, selectedEarnCode, hours, description,
                                    earnCodeObj.getAccrualCategory(), selectedAssignment, requestStatus,
                                    leaveBlockType, currentDate, firstDay.getEnd());

                            if (!currentLeaveBlocks.contains(leaveBlock)) {
                                newlyAddedLeaveBlocks.add(leaveBlock);
                                currentLeaveBlocks.add(leaveBlock);
                            }

                        }
                    }
                } else {

                    if (leaveBlockType.equalsIgnoreCase(LMConstants.LEAVE_BLOCK_TYPE.TIME_CALENDAR)) {
                        hours = applyInflateMinHoursAndFactor(earnCodeObj, hours);
                    }
                    hours = negateHoursIfNecessary(leaveBlockType, hours);
                    LeaveBlockBo leaveBlock = buildLeaveBlock(leaveBlockInt.getStart().toLocalDate(), docId,
                            principalId, selectedEarnCode, hours, description, earnCodeObj.getAccrualCategory(),
                            selectedAssignment, requestStatus, leaveBlockType, null, null);
                    if (!currentLeaveBlocks.contains(leaveBlock)) {
                        newlyAddedLeaveBlocks.add(leaveBlock);
                        currentLeaveBlocks.add(leaveBlock);
                    }
                }
            }
        }
    }
    saveLeaveBlockBos(currentLeaveBlocks);
    for (LeaveBlockBo leaveblockbo : newlyAddedLeaveBlocks) {
        if (leaveblockbo != null) {
            if (leaveblockbo.getDocumentId() == null) {
                leaveblockbo.setDocumentId(docId);
            }
            String principalName = KimApiServiceLocator.getIdentityService()
                    .getDefaultNamesForPrincipalId(HrContext.getPrincipalId()).getDefaultName()
                    .getCompositeName();
            addNote(docId, principalId, "LeaveBlock on " + leaveblockbo.getLeaveLocalDate()
                    + " was added on this Leave Calendar by " + principalName + " on your behalf");
        }
    }

    return ModelObjectUtils.transform(newlyAddedLeaveBlocks, toLeaveBlock);
}

From source file:org.kuali.kra.committee.service.impl.CommitteeScheduleServiceImpl.java

/**
 * Helper method to test if date is available (non conflicting).
 * @param committeeSchedules/*from   w  w  w .j  a va 2 s.  c o  m*/
 * @param date
 * @return
 */
protected Boolean isDateAvailable(List<CommitteeSchedule> committeeSchedules, java.sql.Date date) {
    boolean retVal = true;
    for (CommitteeSchedule committeeSchedule : committeeSchedules) {
        Date scheduledDate = committeeSchedule.getScheduledDate();
        if ((scheduledDate != null) && DateUtils.isSameDay(scheduledDate, date)) {
            retVal = false;
            break;
        }
    }
    return retVal;
}

From source file:org.kuali.kra.committee.web.CommitteeScheduleAddSeleniumTest.java

/**
 * Test the weekly recurrence option for "every Monday".
 * /*from w  ww. j  a v a2s  .c o m*/
 * @throws Exception
 */
@Test
public void testCommitteeScheduleWeeklyRecurranceMonday() throws Exception {
    helper.createCommittee();
    helper.clickCommitteeSchedulePage();

    Date scheduleStartDate = new Date();
    Date scheduleEndDate = DateUtils.addDays(scheduleStartDate, 7);

    helper.set(HELPER_SCHEDULE_START_DATE_ID, fullFormatter.format(scheduleStartDate));
    helper.set(HELPER_TIME_ID, TIME);
    helper.set(HELPER_PLACE_ID, PLACE);
    helper.set(HELPER_RECURRENCE_TYPE_ID, RECURRENCE_TYPE_WEEKLY);
    helper.set(HELPER_WEEKLY_SCHEDULE_SCHEDULE_END_DATE_ID, fullFormatter.format(scheduleEndDate));

    helper.click(ADD_EVENT_BUTTON);

    helper.assertNoPageErrors();

    Date scheduleMonday = getMonday(scheduleStartDate);
    Date deadlineDateMonday = DateUtils.addDays(scheduleMonday, -1);

    if (DateUtils.isSameDay(scheduleStartDate, scheduleMonday)) {
        Date scheduleNextMonday = DateUtils.addDays(scheduleMonday, 7);
        Date deadlineDateNextMonday = DateUtils.addDays(scheduleNextMonday, -1);

        helper.assertTableRowCount(TABLE_ID, 5);

        helper.assertElementContains(String.format(LIST_SCHEDULE_DATE_ID, 0),
                fullFormatter.format(scheduleMonday));
        helper.assertTableCellValueContains(TABLE_ID, 2, 1, dayFormatter.format(scheduleMonday).toUpperCase());
        helper.assertElementContains(String.format(LIST_PROTOCOL_SUB_DEADLINE_ID, 0),
                fullFormatter.format(deadlineDateMonday));

        helper.assertElementContains(String.format(LIST_SCHEDULE_DATE_ID, 1),
                fullFormatter.format(scheduleNextMonday));
        helper.assertTableCellValueContains(TABLE_ID, 3, 1,
                dayFormatter.format(scheduleNextMonday).toUpperCase());
        helper.assertElementContains(String.format(LIST_PROTOCOL_SUB_DEADLINE_ID, 1),
                fullFormatter.format(deadlineDateNextMonday));
    } else {
        helper.assertTableRowCount(TABLE_ID, 4);

        helper.assertElementContains(String.format(LIST_SCHEDULE_DATE_ID, 0),
                fullFormatter.format(scheduleMonday));
        helper.assertTableCellValueContains(TABLE_ID, 2, 1, dayFormatter.format(scheduleMonday).toUpperCase());
        helper.assertElementContains(String.format(LIST_PROTOCOL_SUB_DEADLINE_ID, 0),
                fullFormatter.format(deadlineDateMonday));
    }
}