Example usage for org.joda.time LocalDate getDayOfMonth

List of usage examples for org.joda.time LocalDate getDayOfMonth

Introduction

In this page you can find the example usage for org.joda.time LocalDate getDayOfMonth.

Prototype

public int getDayOfMonth() 

Source Link

Document

Get the day of month field value.

Usage

From source file:org.libreplan.importers.notifications.realization.SendEmailOnMilestoneReached.java

License:Open Source License

public void checkMilestoneDate() {
    List<TaskElement> milestones = taskElementDAO.getTaskElementsWithMilestones();

    LocalDate date = new LocalDate();
    int currentYear = date.getYear();
    int currentMonth = date.getMonthOfYear();
    int currentDay = date.getDayOfMonth();

    for (TaskElement item : milestones) {
        if (item.getDeadline() != null) {

            LocalDate deadline = item.getDeadline();
            int deadlineYear = deadline.getYear();
            int deadlineMonth = deadline.getMonthOfYear();
            int deadlineDay = deadline.getDayOfMonth();

            if (currentYear == deadlineYear && currentMonth == deadlineMonth && currentDay == deadlineDay) {
                sendEmailNotificationToManager(item);
            }//from  www.  jav  a2  s  .c om

        }
    }
}

From source file:org.libreplan.web.costcategories.CostCategoryCRUDController.java

License:Open Source License

/**
 * Append a Datebox "init date" to row./*w  ww .j a v  a2  s.c  om*/
 *
 * @param row
 */
private void appendDateboxInitDate(final Row row) {
    Datebox initDateBox = new Datebox();
    bindDateboxInitDate(initDateBox, row.getValue());
    initDateBox.setConstraint("no empty:" + _("Start date cannot be empty"));
    row.appendChild(initDateBox);

    initDateBox.addEventListener("onChange", new EventListener() {
        @Override
        public void onEvent(Event event) {
            // Updates the constraint of the endDate box with the new date
            LocalDate initDate = ((HourCost) row.getValue()).getInitDate();
            Datebox endDateBox = (Datebox) row.getChildren().get(4);
            endDateBox.setConstraint("after " + String.format("%04d", initDate.getYear())
                    + String.format("%02d", initDate.getMonthOfYear())
                    + String.format("%02d", initDate.getDayOfMonth()));
        }
    });
}

From source file:org.libreplan.web.costcategories.CostCategoryCRUDController.java

License:Open Source License

/**
 * Binds Datebox "init date" to the corresponding attribute of a {@link HourCost}.
 *
 * @param dateBoxInitDate//from   ww  w  .  j a  v a  2s.co  m
 * @param hourCost
 */
private void bindDateboxInitDate(final Datebox dateBoxInitDate, final HourCost hourCost) {
    Util.bind(dateBoxInitDate, new Util.Getter<Date>() {
        @Override
        public Date get() {
            LocalDate dateTime = hourCost.getInitDate();
            if (dateTime != null) {
                /* TODO resolve deprecated */
                return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1,
                        dateTime.getDayOfMonth());
            } else {
                Date now = new Date();
                hourCost.setInitDate(new LocalDate(now));
                return now;
            }
        }
    }, new Util.Setter<Date>() {
        @Override
        public void set(Date value) {
            if (value != null) {
                /* TODO resolve deprecated */
                hourCost.setInitDate(
                        new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate()));
            } else {
                hourCost.setInitDate(null);
            }
        }
    });
}

From source file:org.libreplan.web.costcategories.CostCategoryCRUDController.java

License:Open Source License

/**
 * Append a Datebox "end date" to row./*from  www . ja  v  a2  s .  c  om*/
 *
 * @param row
 */
private void appendDateboxEndDate(Row row) {
    Datebox endDateBox = new Datebox();
    bindDateboxEndDate(endDateBox, row.getValue());
    LocalDate initDate = ((HourCost) row.getValue()).getInitDate();
    if (initDate != null) {
        endDateBox.setConstraint("after " + String.format("%04d", initDate.getYear())
                + String.format("%02d", initDate.getMonthOfYear())
                + String.format("%02d", initDate.getDayOfMonth()));
    }
    row.appendChild(endDateBox);
}

From source file:org.libreplan.web.costcategories.CostCategoryCRUDController.java

License:Open Source License

/**
 * Binds Datebox "init date" to the corresponding attribute of a {@link HourCost}.
 *
 * @param dateBoxEndDate//from   w w w .j a v  a2  s  .c  o  m
 * @param hourCost
 */
private void bindDateboxEndDate(final Datebox dateBoxEndDate, final HourCost hourCost) {
    Util.bind(dateBoxEndDate, new Util.Getter<Date>() {
        @Override
        public Date get() {
            LocalDate dateTime = hourCost.getEndDate();
            if (dateTime != null) {
                /* TODO resolve deprecated */
                return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1,
                        dateTime.getDayOfMonth());
            }
            return null;
        }
    }, new Util.Setter<Date>() {
        @Override
        public void set(Date value) {
            if (value != null) {
                /* TODO resolve deprecated */
                hourCost.setEndDate(
                        new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate()));
            } else {
                hourCost.setEndDate(null);
            }
        }
    });
}

From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java

License:Open Source License

/**
 * Append a Datebox "init date" to row.//from   w w  w. j av  a2  s .  co  m
 *
 * @param row
 */
private void appendDateboxInitDate(final Row row) {
    Datebox initDateBox = new Datebox();
    bindDateboxInitDate(initDateBox, row.getValue());
    initDateBox.setConstraint("no empty:" + _("Start date cannot be empty"));
    row.appendChild(initDateBox);

    initDateBox.addEventListener("onChange", new EventListener() {

        @Override
        public void onEvent(Event event) {
            // Updates the constraint of the endDate box with the new date
            LocalDate initDate = ((ResourcesCostCategoryAssignment) row.getValue()).getInitDate();
            Datebox endDateBox = (Datebox) row.getChildren().get(2);
            endDateBox.setConstraint("after " + String.format("%04d", initDate.getYear())
                    + String.format("%02d", initDate.getMonthOfYear())
                    + String.format("%02d", initDate.getDayOfMonth()));
        }
    });
}

From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java

License:Open Source License

/**
 * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment}.
 *
 * @param dateBoxInitDate// www  . j a  v  a  2  s  . c o  m
 * @param assignment
 */
private void bindDateboxInitDate(final Datebox dateBoxInitDate,
        final ResourcesCostCategoryAssignment assignment) {

    Util.bind(dateBoxInitDate, new Util.Getter<Date>() {
        @Override
        public Date get() {
            LocalDate dateTime = assignment.getInitDate();
            /* TODO resolve deprecated */
            return dateTime != null
                    ? new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1,
                            dateTime.getDayOfMonth())
                    : null;
        }
    }, new Util.Setter<Date>() {
        @Override
        public void set(Date value) {
            if (value != null) {
                /* TODO resolve deprecated */
                assignment.setInitDate(
                        new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate()));
            } else {
                assignment.setInitDate(null);
            }
        }
    });
}

From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java

License:Open Source License

/**
 * Append a Datebox "end date" to row./*from ww w  .  j av  a  2s. c  om*/
 *
 * @param row
 */
private void appendDateboxEndDate(Row row) {
    Datebox endDateBox = new Datebox();
    bindDateboxEndDate(endDateBox, row.getValue());
    LocalDate initDate = ((ResourcesCostCategoryAssignment) row.getValue()).getInitDate();

    if (initDate != null) {
        endDateBox.setConstraint("after " + String.format("%04d", initDate.getYear())
                + String.format("%02d", initDate.getMonthOfYear())
                + String.format("%02d", initDate.getDayOfMonth()));
    }
    row.appendChild(endDateBox);
}

From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java

License:Open Source License

/**
 * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment}.
 *
 * @param dateBoxEndDate//from  ww  w . j  a v a2  s.  co m
 * @param assignment
 */
private void bindDateboxEndDate(final Datebox dateBoxEndDate,
        final ResourcesCostCategoryAssignment assignment) {
    Util.bind(dateBoxEndDate, new Util.Getter<Date>() {
        @Override
        public Date get() {
            LocalDate dateTime = assignment.getEndDate();
            /* TODO resolve deprecated */
            return dateTime != null
                    ? new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1,
                            dateTime.getDayOfMonth())
                    : null;
        }
    }, new Util.Setter<Date>() {
        @Override
        public void set(Date value) {
            if (value != null) {
                /* TODO resolve deprecated */
                assignment.setEndDate(
                        new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate()));
            } else {
                assignment.setEndDate(null);
            }
        }
    });
}

From source file:org.libreplan.web.planner.allocation.AdvancedAllocationController.java

License:Open Source License

private boolean isBeforeLatestConsolidation(DetailItem item) {
    if (!(task).hasConsolidations())
        return false;

    LocalDate d = ((Task) task).getFirstDayNotConsolidated().getDate();

    DateTime firstDayNotConsolidated = new DateTime(d.getYear(), d.getMonthOfYear(), d.getDayOfMonth(), 0, 0, 0,
            0);//from   ww w .ja v a 2  s  .  com

    return item.getStartDate().compareTo(firstDayNotConsolidated) < 0;
}