List of usage examples for org.joda.time LocalDate getMonthOfYear
public int getMonthOfYear()
From source file:org.libreplan.web.costcategories.CostCategoryCRUDController.java
License:Open Source License
/** * Append a Datebox "init date" to row./* ww w. jav a 2 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// ww w. j a v a 2 s . 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 w ww. j a v a2 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/*from w w w .j a v a2s . com*/ * @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 ww w.j a v a 2 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 = ((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//from ww w . j a va 2 s. com * @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.//w ww . jav a 2 s .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// w w w . j av a 2 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 a2 s .co m*/ return item.getStartDate().compareTo(firstDayNotConsolidated) < 0; }
From source file:org.libreplan.web.users.dashboard.PersonalTimesheetDTO.java
License:Open Source License
/** * Returns a string representing the personal timehseet in a given * <code>date</code> depending on the <code>periodicity</code>. *///w ww . j a v a 2 s. c o m public static String toString(PersonalTimesheetsPeriodicityEnum periodicity, LocalDate date) { switch (periodicity) { case WEEKLY: LocalDate start = periodicity.getStart(date); LocalDate end = periodicity.getEnd(date); String string = date.toString("w"); if (start.getMonthOfYear() == end.getMonthOfYear()) { string += " (" + date.toString(MMMM_Y_PATTERN) + ")"; } else { if (start.getYear() == end.getYear()) { string += " (" + start.toString("MMMM") + " - " + end.toString(MMMM_Y_PATTERN) + ")"; } else { string += " (" + start.toString(MMMM_Y_PATTERN) + " - " + end.toString(MMMM_Y_PATTERN) + ")"; } } return _("Week {0}", string); case TWICE_MONTHLY: return (date.getDayOfMonth() <= 15) ? _("{0} 1st fortnight", date.toString(MMMM_Y_PATTERN)) : _("{0} 2nd fortnight", date.toString(MMMM_Y_PATTERN)); case MONTHLY: default: return date.toString(MMMM_Y_PATTERN); } }