List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:pt.ist.bennu.core.domain.scheduler.TaskConfiguration.java
License:Open Source License
public boolean shouldRunNow(DateTime now) { final int min = now.getMinuteOfHour(); final int hour = now.getHourOfDay(); final int day = now.getDayOfMonth(); final int month = now.getMonthOfYear(); final int dayofweek = now.getDayOfWeek(); if (matchField(getMinute(), min) && matchField(getHour(), hour) && matchField(getDay(), day) && matchField(getMonth(), month) && matchField(getDayofweek(), dayofweek)) { final DateTime lastRun = getLastRun(); return lastRun == null || nowIsAfterLastRun(now, lastRun); }// w ww .ja v a 2 s .c o m return false; }
From source file:pt.ist.bennu.core.domain.scheduler.TaskConfiguration.java
License:Open Source License
private boolean nowIsAfterLastRun(final DateTime now, final DateTime lastRun) { if (now.getYear() > lastRun.getYear()) { return true; }//w ww. j a v a2s.c o m if (now.getMonthOfYear() > lastRun.getMonthOfYear()) { return true; } if (now.getDayOfMonth() > lastRun.getDayOfMonth()) { return true; } if (now.getHourOfDay() > lastRun.getHourOfDay()) { return true; } if (now.getMinuteOfHour() > lastRun.getMinuteOfHour()) { return true; } return false; }
From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.acquisitions.SearchPaymentProcessesAction.java
License:Open Source License
private void fillXlsInfo(Set<PaymentProcess> processes, StyledExcelSpreadsheet spreadsheet, OutputStream outputStream) throws IOException { spreadsheet.newRow();/*from w w w. j a v a 2s .com*/ spreadsheet.addCell(processes.size() + " " + getAcquisitionResourceMessage("label.processes")); spreadsheet.newRow(); setHeaders(spreadsheet); TreeSet<PaymentProcess> sortedProcesses = new TreeSet<PaymentProcess>( PaymentProcess.COMPARATOR_BY_YEAR_AND_ACQUISITION_PROCESS_NUMBER); sortedProcesses.addAll(processes); for (PaymentProcess process : sortedProcesses) { spreadsheet.newRow(); spreadsheet.addCell(process.getAcquisitionProcessId()); spreadsheet.addCell(process.getTypeShortDescription()); AcquisitionItemClassification classification = process.getGoodsOrServiceClassification(); spreadsheet.addCell(classification == null ? " " : classification.getLocalizedName()); spreadsheet.addCell(process.getSuppliersDescription()); spreadsheet.addCell(process.getRequest().getRequestItemsSet().size()); spreadsheet.addCell(process.getProcessStateDescription()); DateTime time = new DateTime(); if (process.getPaymentProcessYear().getYear() != time.getYear()) { time = new DateTime(process.getPaymentProcessYear().getYear().intValue(), 12, 31, 23, 59, 59, 0); } spreadsheet.addCell(describeState(process, time)); DateTime date = process.getDateFromLastActivity(); spreadsheet.addCell((date == null) ? "" : date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear() + " " + date.getHourOfDay() + ":" + date.getMinuteOfHour()); spreadsheet.addCell(process.getRequest().getRequester().getFirstAndLastName()); spreadsheet.addCell(process.getRequest().getRequestingUnit().getName()); final MissionProcess missionProcess = process.getMissionProcess(); spreadsheet.addCell(missionProcess == null ? "" : missionProcess.getProcessNumber()); final Boolean skipSupplierFundAllocation = process.getSkipSupplierFundAllocation(); spreadsheet.addCell(Boolean .toString(skipSupplierFundAllocation != null && skipSupplierFundAllocation.booleanValue())); spreadsheet.addCell(toString(process.getCPVReferences())); final StringBuilder builderAccountingUnit = new StringBuilder(); final StringBuilder builderUnits = new StringBuilder(); for (final Financer financer : process.getFinancersWithFundsAllocated()) { final AccountingUnit accountingUnit = financer.getAccountingUnit(); if (accountingUnit != null) { if (builderAccountingUnit.length() > 0) { builderAccountingUnit.append(", "); } builderAccountingUnit.append(accountingUnit.getName()); } final Unit unit = financer.getUnit(); if (unit != null) { if (builderUnits.length() > 0) { builderUnits.append(", "); } builderUnits.append(unit.getUnit().getAcronym()); } } spreadsheet.addCell(builderAccountingUnit.length() == 0 ? " " : builderAccountingUnit.toString()); spreadsheet.addCell(builderUnits.length() == 0 ? " " : builderUnits.toString()); final Money totalValue = process.getTotalValue(); spreadsheet.addCell((totalValue == null ? Money.ZERO : totalValue).toFormatString()); final StringBuilder fundAllocationNumbers = new StringBuilder(); final StringBuilder commitmentNumbers = new StringBuilder(); final StringBuilder efectiveFundAllocationNumbers = new StringBuilder(); final StringBuilder requestOrderNumber = new StringBuilder(); LocalDate invoiceDate = null; Money invoiceValue = Money.ZERO; if (process instanceof SimplifiedProcedureProcess) { SimplifiedProcedureProcess simplifiedProcedureProcess = (SimplifiedProcedureProcess) process; final AcquisitionRequest acquisitionRequest = simplifiedProcedureProcess.getAcquisitionRequest(); for (PayingUnitTotalBean payingUnitTotal : acquisitionRequest.getTotalAmountsForEachPayingUnit()) { if ((simplifiedProcedureProcess.getFundAllocationPresent()) && (payingUnitTotal.getFinancer().isFundAllocationPresent())) { if (fundAllocationNumbers.length() > 0) { fundAllocationNumbers.append(", "); } fundAllocationNumbers.append(payingUnitTotal.getFinancer().getFundAllocationIds().trim()); } if (commitmentNumbers.length() > 0) { fundAllocationNumbers.append(", "); } String commitmentNumber = payingUnitTotal.getFinancer().getCommitmentNumber(); if (commitmentNumber != null) { commitmentNumber = commitmentNumber.trim(); if (commitmentNumber.length() > 0) { commitmentNumbers.append(commitmentNumber); } } if ((simplifiedProcedureProcess.getEffectiveFundAllocationPresent()) && (payingUnitTotal.getFinancer().isEffectiveFundAllocationPresent())) { if (efectiveFundAllocationNumbers.length() > 0) { efectiveFundAllocationNumbers.append(", "); } efectiveFundAllocationNumbers .append(payingUnitTotal.getFinancer().getEffectiveFundAllocationIds().trim()); } } boolean hasFullInvoice = false; for (final Invoice invoice : acquisitionRequest.getInvoices()) { // final AcquisitionInvoice acquisitionInvoice = (AcquisitionInvoice) invoice; final LocalDate localDate = invoice.getInvoiceDate(); if (invoiceDate == null || invoiceDate.isBefore(localDate)) { invoiceDate = localDate; } hasFullInvoice = true; // if (!hasFullInvoice) { // final String confirmationReport = acquisitionInvoice.getConfirmationReport(); // if (confirmationReport == null) { // hasFullInvoice = true; // } else { // for (int i = 0; i < confirmationReport.length(); ) { // final int ulli = confirmationReport.indexOf("<ul><li>", i); // final int q = confirmationReport.indexOf(" - Quantidade:", ulli); // final int ulliClose = confirmationReport.indexOf("</li></ul>", q); // final String itemDescription = confirmationReport.substring(i + "<ul><li>".length(), q); // final int quantity = Integer.parseInt(confirmationReport.substring(q + " - Quantidade:".length(), ulliClose)); // // invoiceValue = invoiceValue.add(calculate(acquisitionRequest, itemDescription, quantity)); // } // } // } } if (hasFullInvoice) { invoiceValue = totalValue; } final PurchaseOrderDocument purchaseOrderDocument = simplifiedProcedureProcess .getPurchaseOrderDocument(); if (purchaseOrderDocument != null) { requestOrderNumber.append(purchaseOrderDocument.getRequestId()); } } spreadsheet.addCell(fundAllocationNumbers.length() == 0 ? " " : fundAllocationNumbers.toString()); spreadsheet.addCell(commitmentNumbers.length() == 0 ? " " : commitmentNumbers.toString()); spreadsheet.addCell(requestOrderNumber.length() == 0 ? " " : requestOrderNumber.toString()); spreadsheet.addCell( efectiveFundAllocationNumbers.length() == 0 ? " " : efectiveFundAllocationNumbers.toString()); spreadsheet.addCell(invoiceDate == null ? " " : invoiceDate.toString("yyyy-MM-dd")); spreadsheet.addCell(invoiceValue.toFormatString()); DateTime creationDate = process.getCreationDate(); spreadsheet.addCell(creationDate == null ? " " : creationDate.toString("yyyy-MM-dd")); SortedSet<WorkflowLog> executionLogsSet = new TreeSet<WorkflowLog>( WorkflowLog.COMPARATOR_BY_WHEN_REVERSED); executionLogsSet.addAll(process.getExecutionLogsSet()); DateTime approvalDate = getApprovalDate(process, executionLogsSet); spreadsheet.addCell(approvalDate == null ? " " : approvalDate.toString("yyyy-MM-dd")); DateTime authorizationDate = getAuthorizationDate(process, executionLogsSet); spreadsheet.addCell(authorizationDate == null ? " " : authorizationDate.toString("yyyy-MM-dd")); } }
From source file:pt.ist.fenixedu.vigilancies.service.CreateConvokes.java
License:Open Source License
@Atomic public static void run(List<VigilantWrapper> vigilants, WrittenEvaluation writtenEvaluation, VigilantGroup group, ExamCoordinator coordinator, String emailMessage) { group.convokeVigilants(vigilants, writtenEvaluation); Set<Person> recievers = new HashSet<Person>(); Set<String> bccs = new HashSet<String>(); if (emailMessage.length() != 0) { Person person = coordinator.getPerson(); for (VigilantWrapper vigilant : vigilants) { recievers.add(vigilant.getPerson()); }//w w w .j a v a2s.co m String groupEmail = group.getContactEmail(); String replyTo; recievers.addAll(writtenEvaluation.getTeachers()); if (groupEmail != null) { bccs.add(groupEmail); replyTo = groupEmail; } else { replyTo = person.getEmail(); } DateTime date = writtenEvaluation.getBeginningDateTime(); String beginDateString = date.getDayOfMonth() + "/" + date.getMonthOfYear() + "/" + date.getYear(); String subject = BundleUtil.getString("resources.VigilancyResources", "email.convoke.subject", new String[] { group.getEmailSubjectPrefix(), writtenEvaluation.getName(), group.getName(), beginDateString }); new Message(PersonSender.newInstance(person), new ConcreteReplyTo(replyTo).asCollection(), new Recipient(Person.convertToUserGroup(recievers)).asCollection(), Collections.EMPTY_LIST, Collections.EMPTY_LIST, subject, emailMessage, bccs); } }
From source file:pt.ist.fenixedu.vigilancies.ui.struts.action.FenixEduVigilanciesContextListener.java
License:Open Source License
private static void notifyVigilantsOfDeletedEvaluation(WrittenEvaluation writtenEvaluation) { if (!writtenEvaluation.getVigilanciesSet().isEmpty()) { final Set<Person> tos = new HashSet<Person>(); for (VigilantGroup group : VigilantGroup.getAssociatedVigilantGroups(writtenEvaluation)) { tos.clear();/*from ww w . j a va 2 s.co m*/ DateTime date = writtenEvaluation.getBeginningDateTime(); String time = writtenEvaluation.getBeginningDateHourMinuteSecond().toString(); String beginDateString = date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear(); String subject = BundleUtil.getString("resources.VigilancyResources", "email.convoke.subject", new String[] { writtenEvaluation.getName(), group.getName(), beginDateString, time }); String body = BundleUtil.getString("resources.VigilancyResources", "label.writtenEvaluationDeletedMessage", new String[] { writtenEvaluation.getName(), beginDateString, time }); for (Vigilancy vigilancy : writtenEvaluation.getVigilanciesSet()) { Person person = vigilancy.getVigilantWrapper().getPerson(); tos.add(person); } Sender sender = Bennu.getInstance().getSystemSender(); new Message(sender, new ConcreteReplyTo(group.getContactEmail()).asCollection(), new Recipient(Person.convertToUserGroup(tos)).asCollection(), subject, body, ""); } } }
From source file:pt.ist.fenixedu.vigilancies.ui.struts.action.FenixEduVigilanciesContextListener.java
License:Open Source License
private static void notifyVigilantsOfEditedEvaluation(EditWrittenEvaluationEvent event) { WrittenEvaluation writtenEvaluation = event.getInstance(); Date dayDate = event.getDayDate(); Date beginDate = event.getBeginDate(); if (!writtenEvaluation.getVigilanciesSet().isEmpty() && (dayDate != writtenEvaluation.getDayDate() || timeModificationIsBiggerThanFiveMinutes(beginDate, writtenEvaluation.getBeginningDate()))) { final HashSet<Person> tos = new HashSet<Person>(); // VigilantGroup group = // writtenEvaluation.getAssociatedVigilantGroups().iterator().next(); for (VigilantGroup group : VigilantGroup.getAssociatedVigilantGroups(writtenEvaluation)) { tos.clear();/* ww w. java 2 s .c o m*/ DateTime date = writtenEvaluation.getBeginningDateTime(); String time = writtenEvaluation.getBeginningDateHourMinuteSecond().toString(); String beginDateString = date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear(); String subject = String.format("[ %s - %s - %s %s ]", new Object[] { writtenEvaluation.getName(), group.getName(), beginDateString, time }); String body = String.format( "Caro Vigilante,\n\nA prova de avaliao: %1$s %2$s - %3$s foi alterada para %4$td-%4$tm-%4$tY - %5$tH:%5$tM.", new Object[] { writtenEvaluation.getName(), beginDateString, time, dayDate, beginDate }); for (Vigilancy vigilancy : writtenEvaluation.getVigilanciesSet()) { Person person = vigilancy.getVigilantWrapper().getPerson(); tos.add(person); } Sender sender = Bennu.getInstance().getSystemSender(); new Message(sender, new ConcreteReplyTo(group.getContactEmail()).asCollection(), new Recipient(Person.convertToUserGroup(tos)).asCollection(), subject, body, ""); } } }
From source file:pt.ist.fenixedu.vigilancies.ui.struts.action.vigilancy.ConvokeManagement.java
License:Open Source License
public ActionForward confirmConvokes(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ConvokeBean beanWithTeachers = null; if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) { beanWithTeachers = (ConvokeBean) RenderUtils.getViewState("selectVigilantsThatAreTeachers") .getMetaObject().getObject(); }//from w w w .j a v a2s . c o m ConvokeBean beanWithVigilants = (ConvokeBean) RenderUtils.getViewState("selectVigilants").getMetaObject() .getObject(); ConvokeBean beanWithUnavailables = (ConvokeBean) RenderUtils .getViewState("selectVigilantsThatAreUnavailable").getMetaObject().getObject(); List<VigilantWrapper> teachers = null; List<VigilantWrapper> vigilants, unavailables; if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) { teachers = beanWithTeachers.getSelectedTeachers(); } vigilants = beanWithVigilants.getVigilants(); unavailables = beanWithUnavailables.getSelectedUnavailableVigilants(); String convokedVigilants = beanWithVigilants.getTeachersAsString(); String teachersVigilancies = null; if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) { teachersVigilancies = beanWithTeachers.getVigilantsAsString(); vigilants.addAll(teachers); } else { teachersVigilancies = RenderUtils.getResourceString("VIGILANCY_RESOURCES", "label.vigilancy.noone"); } vigilants.addAll(unavailables); beanWithVigilants.setVigilants(vigilants); String email = RenderUtils.getResourceString("VIGILANCY_RESOURCES", "label.vigilancy.emailConvoke"); MessageFormat format = new MessageFormat(email); WrittenEvaluation evaluation = beanWithVigilants.getWrittenEvaluation(); DateTime beginDate = evaluation.getBeginningDateTime(); String date = beginDate.getDayOfMonth() + "/" + beginDate.getMonthOfYear() + "/" + beginDate.getYear(); String minutes = String.format("%02d", new Object[] { beginDate.getMinuteOfHour() }); Object[] args = { evaluation.getFullName(), date, beginDate.getHourOfDay(), minutes, beanWithVigilants.getRoomsAsString(), teachersVigilancies, convokedVigilants, beanWithVigilants.getSelectedVigilantGroup().getRulesLink() }; beanWithVigilants.setEmailMessage(format.format(args)); request.setAttribute("bean", beanWithVigilants); return mapping.findForward("confirmConvokes"); }
From source file:py.gestionpymes.prestamos.prestamos.web.Pagare.java
public Pagare(Prestamo prestamo) { this.prestamo = prestamo; monto = this.prestamo.getTotalOperacion().setScale(0, RoundingMode.HALF_EVEN); setMontoLetras(this.prestamo.getTotalOperacion().setScale(0, RoundingMode.HALF_EVEN)); fechaEmision = this.prestamo.getFechaInicioOperacion(); setFechaEmisionTexto(this.prestamo.getFechaInicioOperacion()); DateTime d = new DateTime(this.prestamo.getFechaInicioOperacion()); setAnio(d.getYear());//from w ww. j av a2 s. c o m setMesNumero(d.getMonthOfYear()); setMesLetra(d.toString("MMMM", new Locale("es", "py"))); setDia(d.getDayOfMonth()); setEmpresaNombre(this.prestamo.getEmpresa() == null ? null : this.prestamo.getEmpresa().getRazonSocial()); setEmpresaRuc(this.prestamo.getEmpresa() == null ? null : this.prestamo.getEmpresa().getRuc()); setDeudor(this.prestamo.getCliente() == null ? null : this.prestamo.getCliente().devuelveNombreCompleto()); setDeudorDoc(this.prestamo.getCliente() == null ? null : this.prestamo.getCliente().getNroDocumento()); setDeudorDireccion(this.prestamo.getCliente() == null ? null : this.prestamo.getCliente().devuelveDireccionParticular()); setDeudorCiudad( this.prestamo.getCliente() == null ? null : this.prestamo.getCliente().devuelveCiudadParticular()); if (prestamo.isFirmaConyugeTitular()) { setDeudorConyuge(this.prestamo.getCliente().getConyuge() == null ? null : this.prestamo.getCliente().getConyuge().devuelveNombreCompleto()); setDeudorConyugeDoc(this.prestamo.getCliente().getConyuge() == null ? null : this.prestamo.getCliente().getConyuge().getNroDocumento()); } setCoDeudor( this.prestamo.getCodeudor() == null ? null : this.prestamo.getCodeudor().devuelveNombreCompleto()); setCoDeudorDoc(this.prestamo.getCodeudor() == null ? null : this.prestamo.getCodeudor().getNroDocumento()); setCoDeudorDireccion(this.prestamo.getCodeudor() == null ? null : this.prestamo.getCodeudor().devuelveDireccionParticular()); setCoDeudorCiudad(this.prestamo.getCodeudor() == null ? null : this.prestamo.getCodeudor().devuelveCiudadParticular()); if (prestamo.isFirmaConyugeCodeudor()) { setCoDeudorConyuge(this.prestamo.getCodeudor().getConyuge() == null ? null : this.prestamo.getCodeudor().getConyuge().devuelveNombreCompleto()); setCoDeudorConyugeDoc(this.prestamo.getCodeudor().getConyuge() == null ? null : this.prestamo.getCodeudor().getConyuge().getNroDocumento()); } setPrestamo_id(this.prestamo.getId() == null ? null : this.prestamo.getId()); }
From source file:rabbit.data.internal.xml.DatatypeUtil.java
License:Apache License
/** * Checks whether the two dates are representing the same year, month, and day * of month.//from ww w . j a va 2 s . co m * * @param date1 The first date. * @param date2 The second date. * @return true if the two dates are representing the same date in time, false * otherwise. */ public static boolean isSameDate(DateTime date1, XMLGregorianCalendar date2) { return (date2.getYear() == date1.getYear()) && (date2.getMonth() == date1.getMonthOfYear()) && (date2.getDay() == date1.getDayOfMonth()); }
From source file:rabbit.data.internal.xml.DatatypeUtil.java
License:Apache License
/** * Converts a {@link DateTime} to {@link XMLGregorianCalendar}. The converted * calendar is a date, which means only the year, month and day of month * fields are set.// w ww .j a va2s . c o m * * @param cal The calendar to convert from. * @return The converted calendar. */ public static XMLGregorianCalendar toXmlDate(DateTime cal) { return datatypeFactory.newXMLGregorianCalendarDate(cal.getYear(), cal.getMonthOfYear(), cal.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED); }