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

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

Introduction

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

Prototype

public static Date addDays(final Date date, final int amount) 

Source Link

Document

Adds a number of days to a date returning a new object.

Usage

From source file:org.kuali.kra.coi.disclosure.CoiDisclosureServiceImpl.java

@Override
public CoiDisclosure versionCoiDisclosure() throws VersionException {
    Map fieldValues = new HashMap();
    fieldValues.put("personId", GlobalVariables.getUserSession().getPrincipalId());

    List<CoiDisclosure> disclosures = (List<CoiDisclosure>) businessObjectService
            .findMatchingOrderBy(CoiDisclosure.class, fieldValues, "sequenceNumber", false);
    CoiDisclosure newDisclosure = null;//  w  w  w  . j a  v  a2 s. c o  m
    if (CollectionUtils.isNotEmpty(disclosures)) {
        newDisclosure = versioningService.createNewVersion(disclosures.get(0));
        newDisclosure.setCoiDisclProjects(null);
        newDisclosure.setCoiDisclosureAttachments(null);
        newDisclosure.setCoiDisclosureNotepads(null);
        newDisclosure.setCoiUserRoles(new ArrayList<CoiUserRole>());
        newDisclosure.setCurrentDisclosure(false);
        newDisclosure.setCertificationTimestamp(null);
        newDisclosure.setDisclosureDispositionCode(CoiDispositionStatus.IN_PROGRESS);
        newDisclosure.setDisclosureStatusCode(CoiDisclosureStatus.IN_PROGRESS);
        newDisclosure.setExpirationDate(
                new Date(DateUtils.addDays(new Date(System.currentTimeMillis()), 365).getTime()));
        newDisclosure.setReviewStatusCode(CoiReviewStatus.IN_PROGRESS);
        newDisclosure.refreshReferenceObject("coiReviewStatus");
    }
    return newDisclosure;
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleDeadlineRuleTest.java

@Test
public void testTrue() {

    new TemplateRuleTest<CommitteeScheduleDeadlineEvent, CommitteeScheduleDeadlineDateRule>() {

        @Override/* www  .j  a  v  a2  s.c  om*/
        protected void prerequisite() {

            List<CommitteeSchedule> committeeSchedules = new ArrayList<CommitteeSchedule>();
            CommitteeSchedule temp = new CommitteeSchedule();
            temp.setScheduledDate(new java.sql.Date(new Date().getTime()));
            Date dt = DateUtils.addDays(new Date(), -1);
            temp.setProtocolSubDeadline(new java.sql.Date(dt.getTime()));
            committeeSchedules.add(temp);

            event = new CommitteeScheduleDeadlineEvent(Constants.EMPTY_STRING, null, null, committeeSchedules,
                    ErrorType.HARDERROR);
            rule = new CommitteeScheduleDeadlineDateRule();
            rule.setErrorReporter(new ErrorReporterImpl());
            expectedReturnValue = true;
        }
    };
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleDeadlineRuleTest.java

@Test
public void testFalse() {
    new TemplateRuleTest<CommitteeScheduleDeadlineEvent, CommitteeScheduleDeadlineDateRule>() {
        @Override//  w w  w  .j a  va  2s.c o  m
        protected void prerequisite() {

            List<CommitteeSchedule> committeeSchedules = new ArrayList<CommitteeSchedule>();
            CommitteeSchedule temp = new CommitteeSchedule();
            temp.setScheduledDate(new java.sql.Date(new Date().getTime()));
            Date dt = DateUtils.addDays(new Date(), 1);
            temp.setProtocolSubDeadline(new java.sql.Date(dt.getTime()));
            committeeSchedules.add(temp);

            event = new CommitteeScheduleDeadlineEvent(Constants.EMPTY_STRING, null, null, committeeSchedules,
                    ErrorType.HARDERROR);
            rule = new CommitteeScheduleDeadlineDateRule();
            rule.setErrorReporter(new ErrorReporterImpl());
            expectedReturnValue = false;
        }
    };
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleFilterDatesRuleTest.java

@Test
public void testTrue() {

    new TemplateRuleTest<CommitteeScheduleFilterEvent, CommitteeScheduleFilterDatesRule>() {

        @Override/*from   ww w . j av a2s  .  c om*/
        protected void prerequisite() {

            ScheduleData scheduleData = new ScheduleData();
            Date dt = DateUtils.addDays(new Date(), 1);
            scheduleData.setFilterStartDate(new java.sql.Date(new Date().getTime()));
            scheduleData.setFilerEndDate(new java.sql.Date(dt.getTime()));

            event = new CommitteeScheduleFilterEvent(Constants.EMPTY_STRING, null, scheduleData, null,
                    ErrorType.HARDERROR);
            rule = new CommitteeScheduleFilterDatesRule();
            rule.setErrorReporter(new ErrorReporterImpl());
            expectedReturnValue = true;
        }
    };
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleFilterDatesRuleTest.java

@Test
public void testFalse() {

    new TemplateRuleTest<CommitteeScheduleFilterEvent, CommitteeScheduleFilterDatesRule>() {

        @Override//from w  w  w .  j a v  a 2s  .  com
        protected void prerequisite() {

            ScheduleData scheduleData = new ScheduleData();
            scheduleData.setFilterStartDate(new java.sql.Date(new Date().getTime()));
            Date endDate = DateUtils.addDays(new Date(), -1);
            scheduleData.setFilerEndDate(new java.sql.Date(endDate.getTime()));

            event = new CommitteeScheduleFilterEvent(Constants.EMPTY_STRING, null, scheduleData, null,
                    ErrorType.HARDERROR);
            rule = new CommitteeScheduleFilterDatesRule();
            rule.setErrorReporter(new ErrorReporterImpl());
            expectedReturnValue = false;
        }
    };
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleStartAndEndDateRuleTest.java

/**
 * This method test's rule for user's DAILY selection. 
 * @throws Exception/*from   www  . j a  va  2  s  . c om*/
 */
@Test
public void testDailyForTrue() throws Exception {

    prerequisite(StyleKey.DAILY);

    scheduleData.setDailySchedule(new DailyScheduleDetails());
    Date dt = DateUtils.addDays(new Date(), 1);
    scheduleData.getDailySchedule().setScheduleEndDate(new java.sql.Date(dt.getTime()));

    testAssertTrue();
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleStartAndEndDateRuleTest.java

/**
 * This method test's rule for user's WEEKLY selection.
 * @throws Exception/* w  ww  .  java 2 s  .com*/
 */
@Test
public void testWeeklyForTrue() throws Exception {

    prerequisite(StyleKey.WEEKLY);

    scheduleData.setWeeklySchedule(new WeeklyScheduleDetails());
    Date dt = DateUtils.addDays(new Date(), 1);
    scheduleData.getWeeklySchedule().setScheduleEndDate(new java.sql.Date(dt.getTime()));

    testAssertTrue();
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleStartAndEndDateRuleTest.java

/**
 * This method test's rule for user's MONTHLY selection.
 * @throws Exception//w w  w .  jav  a  2  s.  co  m
 */
@Test
public void testMonthlyForTrue() throws Exception {

    prerequisite(StyleKey.MONTHLY);

    scheduleData.setMonthlySchedule(new MonthlyScheduleDetails());
    Date dt = DateUtils.addDays(new Date(), 1);
    scheduleData.getMonthlySchedule().setScheduleEndDate(new java.sql.Date(dt.getTime()));

    testAssertTrue();
}

From source file:org.kuali.kra.committee.rules.CommitteeScheduleStartAndEndDateRuleTest.java

/**
 * This method test's rule for user's YEARLY selection.
 * @throws Exception/*from   w w w .  j a  v  a2  s.  c o m*/
 */
@Test
public void testYearlyForTrue() throws Exception {

    prerequisite(StyleKey.YEARLY);

    scheduleData.setYearlySchedule(new YearlyScheduleDetails());
    Date dt = DateUtils.addDays(new Date(), 1);
    scheduleData.getYearlySchedule().setScheduleEndDate(new java.sql.Date(dt.getTime()));

    testAssertTrue();
}

From source file:org.kuali.kra.committee.service.CommitteeBatchCorrespondenceServiceTest.java

private List<Protocol> initProtocols() {
    List<Protocol> protocols = new ArrayList<Protocol>();
    Protocol protocol1 = new Protocol() { //ProtocolTestUtil.getProtocol(this.context)
        private static final long serialVersionUID = 1L;

        @Override//w  ww .ja v a 2s  .  co m
        public void refreshReferenceObject(String referenceObjectName) {
        }

        @Override
        public Integer getNextValue(String key) {
            return 2;
        }

        @Override
        public ProtocolPerson getPrincipalInvestigator() {
            ProtocolPerson pPerson = new ProtocolPerson();
            pPerson.setFullName("PI Test");
            return pPerson;
        }

        public void refreshNonUpdateableReferences() {
        }
    };
    protocol1.setProtocolNumber(PROTOCOL_NUMBER);
    protocol1.setSequenceNumber(SEQUENCE_NUMBER);
    protocol1
            .setExpirationDate(new Date(DateUtils.addDays(new Date(System.currentTimeMillis()), 17).getTime()));
    protocol1.setProtocolActions(new ArrayList<ProtocolActionBase>());
    ProtocolAction protocolAction1 = new ProtocolAction();
    protocolAction1.setActionDate(
            new Timestamp(DateUtils.addDays(new Date(System.currentTimeMillis()), -2).getTime()));
    protocolAction1.setUpdateTimestamp(protocolAction1.getActionDate());
    protocol1.getProtocolActions().add(protocolAction1);
    protocol1.setProtocolDocument(getProtocolDocument("1"));
    protocols.add(protocol1);

    Protocol protocol2 = new Protocol() { //ProtocolTestUtil.getProtocol(this.context)
        private static final long serialVersionUID = 1L;

        @Override
        public void refreshReferenceObject(String referenceObjectName) {
        }

        @Override
        public Integer getNextValue(String key) {
            return 2;
        }

        @Override
        public ProtocolPerson getPrincipalInvestigator() {
            ProtocolPerson pPerson = new ProtocolPerson();
            pPerson.setFullName("PI Test");
            return pPerson;
        }

        public void refreshNonUpdateableReferences() {
        }
    };
    protocol2.setProtocolNumber(PROTOCOL_NUMBER);
    protocol2.setSequenceNumber(SEQUENCE_NUMBER);
    protocol2.setExpirationDate(
            new Date(DateUtils.addDays(new Date(System.currentTimeMillis()), 130).getTime()));
    protocol2.setProtocolActions(new ArrayList<ProtocolActionBase>());
    ProtocolAction protocolAction2 = new ProtocolAction();
    protocolAction2.setActionDate(
            new Timestamp(DateUtils.addDays(new Date(System.currentTimeMillis()), -16).getTime()));
    protocolAction2.setUpdateTimestamp(protocolAction2.getActionDate());
    protocol2.getProtocolActions().add(protocolAction2);
    protocol2.setProtocolDocument(getProtocolDocument("2"));
    protocols.add(protocol2);

    return protocols;
}