List of usage examples for org.joda.time LocalDate toDateTimeAtStartOfDay
public DateTime toDateTimeAtStartOfDay()
From source file:org.kuali.rice.core.api.util.jaxb.LocalDateAdapter.java
License:Educational Community License
@Override public Calendar marshal(LocalDate localDate) throws Exception { if (localDate == null) { return null; }/*from w w w . j a v a 2 s. co m*/ Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(localDate.toDateTimeAtStartOfDay().getMillis()); return calendar; }
From source file:org.libreplan.business.calendars.entities.CalendarAvailability.java
License:Open Source License
public boolean isActiveBetween(LocalDate filterStartDate, LocalDate filterEndDate) { if (filterStartDate == null && filterEndDate == null) { return true; }// w ww. ja v a 2s .co m if (filterStartDate == null) { if (endDate == null) { return startDate.compareTo(filterEndDate) <= 0; } return startDate.compareTo(filterEndDate) <= 0 || endDate.compareTo(filterEndDate) <= 0; } if (filterEndDate == null) { return endDate == null || startDate.compareTo(filterStartDate) >= 0 || endDate.compareTo(filterStartDate) >= 0; } if (endDate == null) { return startDate.compareTo(filterStartDate) <= 0 || startDate.compareTo(filterEndDate) <= 0; } Interval filterPeriod = new Interval(filterStartDate.toDateTimeAtStartOfDay(), filterEndDate.plusDays(1).toDateTimeAtStartOfDay()); Interval activationPeriod = new Interval(startDate.toDateTimeAtStartOfDay(), endDate.plusDays(1).toDateTimeAtStartOfDay()); return filterPeriod.overlaps(activationPeriod); }
From source file:org.libreplan.business.planner.entities.TaskElement.java
License:Open Source License
public void setDeadline(LocalDate deadline) { this.deadline = deadline; if (taskSource != null && taskSource.getOrderElement() != null) { taskSource.getOrderElement()/* w w w . j av a2s .co m*/ .setDeadline((deadline == null) ? null : deadline.toDateTimeAtStartOfDay().toDate()); } }
From source file:org.libreplan.importers.ExportTimesheetsToTim.java
License:Open Source License
/** * exports time sheets to Tim/* w ww . j a va 2 s. com*/ * * @param productCode * the product code * @param order * the order * @param connector * the connector * * @return true if export is succeeded, false otherwise */ private void exportTimesheets(String productCode, Order order, Connector connector) { synchronizationInfo = new SynchronizationInfo( _("Export product code {0}, project {1}", productCode, order.getName())); Map<String, String> properties = connector.getPropertiesAsMap(); String url = properties.get(PredefinedConnectorProperties.SERVER_URL); String userName = properties.get(PredefinedConnectorProperties.USERNAME); String password = properties.get(PredefinedConnectorProperties.PASSWORD); int nrDaysTimesheetToTim = Integer .parseInt(properties.get(PredefinedConnectorProperties.TIM_NR_DAYS_TIMESHEET)); LocalDate dateNrOfDaysBack = new LocalDate().minusDays(nrDaysTimesheetToTim); List<WorkReportLine> workReportLines = order .getWorkReportLines(dateNrOfDaysBack.toDateTimeAtStartOfDay().toDate(), new Date(), true); if (workReportLines == null || workReportLines.isEmpty()) { LOG.warn("No work reportlines are found for order: '" + order.getName() + "'"); synchronizationInfo .addFailedReason(_("No work reportlines are found for order: \"{0}\"", order.getName())); return; } List<TimeRegistrationDTO> timeRegistrationDTOs = new ArrayList<TimeRegistrationDTO>(); for (WorkReportLine workReportLine : workReportLines) { TimeRegistrationDTO timeRegistrationDTO = createExportTimeRegistration(productCode, workReportLine); if (timeRegistrationDTO != null) { timeRegistrationDTOs.add(timeRegistrationDTO); } } if (timeRegistrationDTOs.isEmpty()) { LOG.warn("Unable to crate timeregistration for request"); synchronizationInfo.addFailedReason(_("Unable to crate time registration for request")); return; } TimeRegistrationRequestDTO timeRegistrationRequestDTO = new TimeRegistrationRequestDTO(); timeRegistrationRequestDTO.setTimeRegistrations(timeRegistrationDTOs); TimeRegistrationResponseDTO timeRegistrationResponseDTO = TimSoapClient.sendRequestReceiveResponse(url, userName, password, timeRegistrationRequestDTO, TimeRegistrationResponseDTO.class); if (timeRegistrationResponseDTO == null) { LOG.error("No response or exception in response"); synchronizationInfo.addFailedReason(_("No response or exception in response")); return; } if (isRefsListEmpty(timeRegistrationResponseDTO.getRefs())) { LOG.warn("Registration response with empty refs"); synchronizationInfo.addFailedReason(_("Registration response with empty refs")); return; } saveSyncInfoOnAnotherTransaction(productCode, order); }
From source file:org.libreplan.web.calendars.BaseCalendarEditionController.java
License:Open Source License
private static Date toDate(LocalDate date) { return date == null ? null : date.toDateTimeAtStartOfDay().toDate(); }
From source file:org.libreplan.web.calendars.BaseCalendarModel.java
License:Open Source License
@Override public Date getCurrentStartDate() { CalendarData calendarData = getCurrentVersion(); if (calendarData != null) { LocalDate startDate = getValidFrom(calendarData); return startDate != null ? startDate.toDateTimeAtStartOfDay().toDate() : null; }/*from w ww . j a v a 2 s. c o m*/ return null; }
From source file:org.libreplan.web.common.Util.java
License:Open Source License
/** * Format specific <code>date</code> using the {@link DateFormat#DEFAULT} format and showing only date without time. *//*w ww .j ava 2 s . c o m*/ public static String formatDate(LocalDate date) { return date == null ? "" : formatDate(date.toDateTimeAtStartOfDay()); }
From source file:org.libreplan.web.limitingresources.ManualAllocationController.java
License:Open Source License
private Date toDate(LocalDate date) { return date.toDateTimeAtStartOfDay().toDate(); }
From source file:org.libreplan.web.orders.ManageOrderElementAdvancesController.java
License:Open Source License
public void validateMeasurementDate(Component comp, Date value) { AdvanceMeasurement advanceMeasurement = getAdvanceMeasurementByComponent(comp); if (manageOrderElementAdvancesModel.canRemoveOrChange(advanceMeasurement)) { if (value == null && advanceMeasurement != null) { advanceMeasurement.setDate(null); ((Datebox) comp).setValue(null); throw new WrongValueException(comp, _("cannot be empty")); } else {//from w w w . jav a 2s. co m String errorMessage = validateDateAdvanceMeasurement(new LocalDate(value), advanceMeasurement); LocalDate date = null; if (advanceMeasurement != null) date = advanceMeasurement.getDate(); if (date != null) ((Datebox) comp).setValue(date.toDateTimeAtStartOfDay().toDate()); if (errorMessage != null) throw new WrongValueException(comp, errorMessage); } } }
From source file:org.libreplan.web.orders.ManageOrderElementAdvancesModel.java
License:Open Source License
@Override @Transactional(readOnly = true)//from w w w .ja va2s.c o m public XYModel getChartData(Set<AdvanceAssignment> selectedAdvances) { XYModel xyModel = new SimpleXYModel(); for (AdvanceAssignment each : selectedAdvances) { DirectAdvanceAssignment directAdvanceAssignment; if (each instanceof DirectAdvanceAssignment) { directAdvanceAssignment = (DirectAdvanceAssignment) each; } else { directAdvanceAssignment = calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) each); } if (directAdvanceAssignment != null) { String title = getInfoAdvanceAssignment(directAdvanceAssignment); SortedSet<AdvanceMeasurement> listAdvanceMeasurements = directAdvanceAssignment .getAdvanceMeasurements(); if (listAdvanceMeasurements.size() > 1) { for (AdvanceMeasurement advanceMeasurement : listAdvanceMeasurements) { BigDecimal value = advanceMeasurement.getValue(); if ((selectedAdvances.size() > 1) && (value != null) && (value.compareTo(BigDecimal.ZERO) > 0)) { BigDecimal maxValue = directAdvanceAssignment.getMaxValue(); value = value.setScale(2).divide(maxValue, RoundingMode.DOWN); } LocalDate date = advanceMeasurement.getDate(); if ((value != null) && (date != null)) { xyModel.addValue(title, date.toDateTimeAtStartOfDay().getMillis(), value); } } } } } return xyModel; }