Example usage for org.joda.time LocalDate getYear

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:org.kitodo.production.model.bibliography.course.CourseToGerman.java

License:Open Source License

/**
 * The method appendDate() writes a date to the buffer.
 *
 * @param buffer/*from w w w.  j a v a2s .c om*/
 *            Buffer to write to
 * @param date
 *            Date to write
 */
private static void appendDate(StringBuilder buffer, LocalDate date) {
    buffer.append(date.getDayOfMonth());
    buffer.append(". ");
    buffer.append(MONTH_NAMES[date.getMonthOfYear()]);
    buffer.append(' ');
    buffer.append(date.getYear());
}

From source file:org.kitodo.production.plugin.opac.pica.PicaPlugin.java

License:Open Source License

/**
 * The function toRecentLocalDate() interprets a String of scheme "dd-mm-yy"
 * as a LocalDate within the last 100 years up to a given reference date.
 *
 * @param dd_mm_yy//from www . j  ava  2s .c  om
 *            a date String to interpret
 * @param upTo
 *            a reference date
 * @return the date value as LocalDate
 */
private static LocalDate toRecentLocalDate(String dd_mm_yy, LocalDate upTo) {
    int centuryPrefix = upTo.getYear() / 100;
    String[] fields = dd_mm_yy.split("-");
    int year = (100 * centuryPrefix) + Integer.parseInt(fields[2]);
    if (year > upTo.getYear()) {
        year -= 100;
    }
    return new LocalDate(year, Integer.parseInt(fields[1]), Integer.parseInt(fields[0]));
}

From source file:org.kuali.kpme.tklm.leave.summary.service.LeaveSummaryServiceImpl.java

License:Educational Community License

private String getYearKey(LocalDate leaveDate, LeavePlan lp) {
    String yearKey = Integer.toString(leaveDate.getYear());

    LocalDate leavePlanDate = new LocalDate(leaveDate.getYear(),
            Integer.parseInt(lp.getCalendarYearStartMonth()),
            Integer.parseInt(lp.getCalendarYearStartDayOfMonth()));

    if (leaveDate.isBefore(leavePlanDate)) {
        yearKey = Integer.toString(leaveDate.getYear() - 1);
    }//from  ww w . j a va  2  s  . c  o m
    return yearKey;
}

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   w  w w.  j a  v  a2  s . co  m*/

        }
    }
}

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

License:Open Source License

/**
 * Append a Datebox "init date" to row./* w w  w .ja  v a2 s .  c o 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 = ((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  w w w  .  j  ava 2  s . c  o  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 ww  w. j av a  2  s  . com
 *
 * @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/*w  w w  .  j av  a2s .  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  ww . j a  va 2s  .  c  o  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 . ja  va  2  s  .c om
 * @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);
            }
        }
    });
}