Example usage for org.joda.time DateTime getMonthOfYear

List of usage examples for org.joda.time DateTime getMonthOfYear

Introduction

In this page you can find the example usage for org.joda.time DateTime getMonthOfYear.

Prototype

public int getMonthOfYear() 

Source Link

Document

Get the month of year field value.

Usage

From source file:org.fenixedu.academic.service.CreateUnavailablePeriod.java

License:Open Source License

private static void sendEmail(Person person, DateTime begin, DateTime end, String justification,
        List<VigilantGroup> groups) {
    for (VigilantGroup group : groups) {
        String bccs = group.getContactEmail();

        String beginDate = begin.getDayOfMonth() + "/" + begin.getMonthOfYear() + "/" + begin.getYear() + " - "
                + String.format("%02d", begin.getHourOfDay()) + ":"
                + String.format("%02d", begin.getMinuteOfHour()) + "h";
        String endDate = end.getDayOfMonth() + "/" + end.getMonthOfYear() + "/" + end.getYear() + " - "
                + String.format("%02d", end.getHourOfDay()) + ":" + String.format("%02d", end.getMinuteOfHour())
                + "h";
        ;/*from w ww. ja  va 2 s.  c  o m*/
        String message = BundleUtil.getString("resources.VigilancyResources", "email.convoke.unavailablePeriod",
                new String[] { person.getName(), beginDate, endDate, justification });

        String subject = BundleUtil.getString("resources.VigilancyResources",
                "email.convoke.unavailablePeriod.subject", new String[] { group.getName() });

        Sender sender = Bennu.getInstance().getSystemSender();
        new Message(sender, new ConcreteReplyTo(group.getContactEmail()).asCollection(), Collections.EMPTY_LIST,
                subject, message, bccs);
    }
}

From source file:org.fenixedu.academic.servlet.taglib.GanttDiagramTagLib.java

License:Open Source License

private StringBuilder generateGanttDiagramInTimeMode(BigDecimal tableWidth) throws JspException {
    StringBuilder builder = new StringBuilder();

    if (!getEvents().isEmpty()) {
        if (isShowPeriod() && isShowObservations()) {
            builder.append("<table style=\"width:")
                    .append(tableWidth.add(BigDecimal.valueOf(FIXED_COLUMNS_SIZE_EM)))
                    .append("em;\" class=\"tcalendar thlight\">");
        } else {/*from www .ja v  a 2s .  c o  m*/
            builder.append("<table class=\"tcalendar thlight\">");
        }

        generateHeaders(builder);

        int numberOfUnits = getNumberOfUnits();

        String selectedEvent = getRequest().getParameter(getEventParameter());
        Object selectedEventObject = getRequest().getAttribute(getEventParameter());

        for (GanttDiagramEvent event : getEvents()) {

            String eventUrl = getRequest().getContextPath() + getEventUrl() + "&amp;" + getEventParameter()
                    + "=" + event.getGanttDiagramEventIdentifier();

            if (event.getGanttDiagramEventUrlAddOns() != null) {
                eventUrl = eventUrl.concat(event.getGanttDiagramEventUrlAddOns());
            }

            final LocalizedString diagramEventName = event.getGanttDiagramEventName();
            String eventName = diagramEventName == null ? "" : diagramEventName.getContent();
            String paddingStyle = "padding-left:" + event.getGanttDiagramEventOffset() * PADDING_LEFT_MULTIPLIER
                    + "px";

            if (event.getGanttDiagramEventIdentifier().equals(selectedEvent) || (selectedEventObject != null
                    && event.getGanttDiagramEventIdentifier().equals(selectedEventObject.toString()))) {
                builder.append("<tr class=\"selected\">");
            } else {
                builder.append("<tr>");
            }

            if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
                builder.append("<td class=\"padded\">").append("<div class=\"nowrap\">");
                builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName)
                        .append("\">");
                builder.append("<a href=\"").append(eventUrl).append("&amp;month=")
                        .append(Month.values()[event.getGanttDiagramEventMonth() - 1].toString()).append("\">")
                        .append(eventName);
            } else {
                builder.append("<td class=\"padded\">")
                        .append("<div style=\"overflow:hidden; width: 14.5em;\" class=\"nowrap\">");
                builder.append("<span style=\"").append(paddingStyle).append("\" title=\"").append(eventName)
                        .append("\">");
                builder.append("<a href=\"").append(eventUrl).append("\">").append(eventName);
            }
            builder.append("</a></span></div></td>");

            for (DateTime day : getGanttDiagramObject().getDays()) {

                int startIndex = 0, endIndex = 0;
                int dayOfMonth = day.getDayOfMonth();
                int monthOfYear = day.getMonthOfYear();
                if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
                    monthOfYear = event.getGanttDiagramEventMonth();
                }
                int year = day.getYear();
                YearMonthDay yearMonthDay = new YearMonthDay(year, monthOfYear, 1);

                isEventToMarkWeekendsAndHolidays = event.isGanttDiagramEventToMarkWeekendsAndHolidays();

                if (!isEventToMarkWeekendsAndHolidays) {
                    builder.append("<td style=\"width: ").append(convertToEm(numberOfUnits))
                            .append("em;\"><div style=\"position: relative;\">");
                }

                if (getViewTypeEnum() == ViewType.YEAR_DAILY) {
                    if (dayOfMonth > yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) {
                        addEmptyDiv(builder);
                        builder.append("</div></td>");
                        continue;
                    }
                }

                specialDiv = false;

                for (Interval interval : event.getGanttDiagramEventSortedIntervals()) {

                    toWrite = null;
                    toMark = true;
                    LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate();
                    if ((event.getGanttDiagramEventDayType(interval) == DayType.SPECIFIC_DAYS)
                            || (event.getGanttDiagramEventDayType(interval) == DayType.WORKDAY)) {
                        if ((localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME)
                                || (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME)
                                || (Holiday.isHoliday(localDate))) {
                            toMark = false;
                        }
                    }
                    if (isEventToMarkWeekendsAndHolidays) {
                        if (Holiday.isHoliday(localDate)) {
                            toWrite = F;
                        } else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) {
                            toWrite = S;
                        } else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) {
                            toWrite = D;
                        }
                    }

                    if (interval.getStart().getYear() <= year && interval.getEnd().getYear() >= year) {

                        if (interval.getStart().getYear() < year && interval.getEnd().getYear() > year) {
                            addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
                        }
                        // Started in same year and Ended after
                        else if (interval.getStart().getYear() == year && interval.getEnd().getYear() > year) {

                            if (interval.getStart().getMonthOfYear() < monthOfYear) {
                                addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                            } else if (interval.getStart().getMonthOfYear() == monthOfYear) {

                                if (interval.getStart().getDayOfMonth() == dayOfMonth) {
                                    startIndex = calculateTimeOfDay(interval.getStart());
                                    addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
                                            convertToEm(startIndex - 1));

                                } else if (interval.getStart().getDayOfMonth() < dayOfMonth) {
                                    addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
                                }
                            }
                        }
                        // Ended in same year and started before
                        else if (interval.getStart().getYear() < year && interval.getEnd().getYear() == year) {

                            if (interval.getEnd().getMonthOfYear() > monthOfYear) {
                                addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                            } else if (interval.getEnd().getMonthOfYear() == monthOfYear) {

                                if (interval.getEnd().getDayOfMonth() > dayOfMonth) {
                                    addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                                } else if (interval.getEnd().getDayOfMonth() == dayOfMonth) {
                                    endIndex = calculateTimeOfDay(interval.getEnd());
                                    addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
                                }
                            }
                        }
                        // Ended and Started In Same Year
                        else if (interval.getStart().getYear() == year && interval.getEnd().getYear() == year) {

                            if (interval.getStart().getMonthOfYear() <= monthOfYear
                                    && interval.getEnd().getMonthOfYear() >= monthOfYear) {

                                if (interval.getStart().getMonthOfYear() == monthOfYear
                                        && interval.getEnd().getMonthOfYear() > monthOfYear) {

                                    if (interval.getStart().getDayOfMonth() == dayOfMonth) {
                                        startIndex = calculateTimeOfDay(interval.getStart());
                                        addSpecialDiv(builder, convertToEm(numberOfUnits - (startIndex - 1)),
                                                convertToEm(startIndex - 1));

                                    } else if (interval.getStart().getDayOfMonth() < dayOfMonth) {
                                        addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);
                                    }

                                } else if (interval.getStart().getMonthOfYear() < monthOfYear
                                        && interval.getEnd().getMonthOfYear() == monthOfYear) {

                                    if (interval.getEnd().getDayOfMonth() > dayOfMonth) {
                                        addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                                    } else if (interval.getEnd().getDayOfMonth() == dayOfMonth) {
                                        endIndex = calculateTimeOfDay(interval.getEnd());
                                        addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
                                    }

                                } else if (interval.getStart().getMonthOfYear() < monthOfYear
                                        && interval.getEnd().getMonthOfYear() > monthOfYear) {
                                    addSpecialDiv(builder, convertToEm(numberOfUnits), EMPTY_UNIT);

                                } else if (interval.getStart().getMonthOfYear() == monthOfYear
                                        && interval.getEnd().getMonthOfYear() == monthOfYear) {

                                    if (interval.getStart().getDayOfMonth() <= dayOfMonth
                                            && interval.getEnd().getDayOfMonth() >= dayOfMonth) {

                                        if (event.isGanttDiagramEventIntervalsLongerThanOneDay()
                                                && (interval.getStart().getDayOfMonth() == dayOfMonth
                                                        || interval.getEnd().getDayOfMonth() > dayOfMonth)) {
                                            startIndex = calculateTimeOfDay(interval.getStart());
                                            addSpecialDiv(builder,
                                                    convertToEm(numberOfUnits - (startIndex - 1)),
                                                    convertToEm(startIndex - 1));
                                        } else if (interval.getStart().getDayOfMonth() == dayOfMonth
                                                && interval.getEnd().getDayOfMonth() > dayOfMonth) {
                                            startIndex = calculateTimeOfDay(interval.getStart());
                                            addSpecialDiv(builder,
                                                    convertToEm(numberOfUnits - (startIndex - 1)),
                                                    convertToEm(startIndex - 1));
                                        }

                                        else if (interval.getStart().getDayOfMonth() < dayOfMonth
                                                && interval.getEnd().getDayOfMonth() == dayOfMonth) {
                                            endIndex = calculateTimeOfDay(interval.getEnd());
                                            addSpecialDiv(builder, convertToEm(endIndex), EMPTY_UNIT);
                                        }

                                        else if (interval.getStart().getDayOfMonth() == dayOfMonth
                                                && interval.getEnd().getDayOfMonth() == dayOfMonth) {

                                            startIndex = calculateTimeOfDay(interval.getStart());
                                            endIndex = calculateTimeOfDay(interval.getEnd());

                                            if (startIndex == endIndex) {
                                                addSpecialDiv(builder, convertToEm(1),
                                                        convertToEm(startIndex - 1));
                                            } else {
                                                addSpecialDiv(builder, convertToEm((endIndex - startIndex) + 1),
                                                        convertToEm(startIndex - 1));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (!isEventToMarkWeekendsAndHolidays) {
                    builder.append("</div></td>");
                } else if (!specialDiv) {
                    builder.append("<td class=\"tdnomark\">");
                    if (dayOfMonth <= yearMonthDay.plusMonths(1).minusDays(1).getDayOfMonth()) {
                        LocalDate localDate = yearMonthDay.withDayOfMonth(dayOfMonth).toLocalDate();
                        if (Holiday.isHoliday(localDate)) {
                            builder.append(F);
                        } else if (localDate.getDayOfWeek() == SATURDAY_IN_JODA_TIME) {
                            builder.append("S");
                        } else if (localDate.getDayOfWeek() == SUNDAY_IN_JODA_TIME) {
                            builder.append("D");
                        }
                    }
                    builder.append("</td>");
                }
            }
            if (isShowPeriod()) {
                builder.append("<td class=\"padded smalltxt\" title=\"")
                        .append(event.getGanttDiagramEventPeriod())
                        .append("\"><div style=\"overflow:hidden;\" class=\"nowrap\">")
                        .append(event.getGanttDiagramEventPeriod()).append("</div></td>");
            }
            if (isShowObservations()) {
                builder.append("<td class=\"padded smalltxt\">")
                        .append(event.getGanttDiagramEventObservations()).append("</td>");
            }
            builder.append("</tr>");
        }
        insertNextAndBeforeLinks(builder);
        builder.append("</table>");
    }
    return builder;
}

From source file:org.fenixedu.academic.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 w  w w.  j  av a 2  s  .c o  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(UserGroup.of(Person.convertToUsers(tos))).asCollection(), subject, body, "");

        }
    }
}

From source file:org.fenixedu.academic.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();/*w w  w .  j  a v  a2s  . co 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(UserGroup.of(Person.convertToUsers(tos))).asCollection(), subject, body, "");
        }
    }
}

From source file:org.fenixedu.academic.ui.struts.action.operator.SubmitPhotoAction.java

License:Open Source License

public ActionForward photoUpload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    PhotographUploadBean photo = getRenderedObject();
    RenderUtils.invalidateViewState();/*from www. j  a v a  2  s  .c o m*/
    String base64Thumbnail = request.getParameter("encodedThumbnail");
    String base64Image = request.getParameter("encodedPicture");
    if (base64Image != null && base64Thumbnail != null) {
        DateTime now = new DateTime();
        photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth()
                + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png");
        photo.setBase64RawContent(base64Image.split(",")[1]);
        photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]);
        photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]);
    }

    ActionMessages actionMessages = new ActionMessages();
    try (InputStream stream = photo.getFileInputStream()) {
        if (stream == null) {
            actionMessages.add("error", new ActionMessage("errors.fileRequired"));
            saveMessages(request, actionMessages);
            return preparePhotoUpload(mapping, actionForm, request, response);
        }
    }

    if (ContentType.getContentType(photo.getContentType()) == null) {
        actionMessages.add("error", new ActionMessage("errors.unsupportedFile"));
        saveMessages(request, actionMessages);
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    if (photo.getRawSize() > MAX_RAW_SIZE) {
        actionMessages.add("error", new ActionMessage("errors.fileTooLarge"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    try {
        photo.processImage();
    } catch (UnableToProcessTheImage e) {
        actionMessages.add("error", new ActionMessage("errors.unableToProcessImage"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    try {
        updatePersonPhoto(photo);
    } catch (Exception e) {
        actionMessages.add("error", new ActionMessage("errors.unableToSaveImage"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return preparePhotoUpload(mapping, actionForm, request, response);
    }

    actionMessages.add("success", new ActionMessage("label.operator.submit.ok", ""));
    saveMessages(request, actionMessages);
    return preparePhotoUpload(mapping, actionForm, request, response);
}

From source file:org.fenixedu.academic.ui.struts.action.person.UploadPhotoDA.java

License:Open Source License

public ActionForward upload(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    PhotographUploadBean photo = getRenderedObject();
    RenderUtils.invalidateViewState();//from   w w w.j av  a2 s . com
    String base64Thumbnail = request.getParameter("encodedThumbnail");
    String base64Image = request.getParameter("encodedPicture");
    if (base64Image != null && base64Thumbnail != null) {
        DateTime now = new DateTime();
        photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth()
                + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png");
        photo.setBase64RawContent(base64Image.split(",")[1]);
        photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]);
        photo.setContentType(base64Image.split(",")[0].split(":")[1].split(";")[0]);
    }

    ActionMessages actionMessages = new ActionMessages();
    try (InputStream stream = photo.getFileInputStream()) {
        if (stream == null) {
            actionMessages.add("fileRequired", new ActionMessage("errors.fileRequired"));
            saveMessages(request, actionMessages);
            return prepare(mapping, actionForm, request, response);
        }
    }

    if (ContentType.getContentType(photo.getContentType()) == null) {
        actionMessages.add("fileUnsupported", new ActionMessage("errors.unsupportedFile"));
        saveMessages(request, actionMessages);
        return prepare(mapping, actionForm, request, response);
    }

    if (photo.getRawSize() > MAX_RAW_SIZE) {
        actionMessages.add("fileTooLarge", new ActionMessage("errors.fileTooLarge"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return prepare(mapping, actionForm, request, response);
    }

    try {
        photo.processImage();
    } catch (UnableToProcessTheImage e) {
        actionMessages.add("unableToProcessImage", new ActionMessage("errors.unableToProcessImage"));
        saveMessages(request, actionMessages);
        photo.deleteTemporaryFiles();
        return prepare(mapping, actionForm, request, response);
    }
    photo.createTemporaryFiles();

    request.setAttribute("preview", true);
    request.setAttribute("photo", photo);
    return mapping.findForward("confirm");
}

From source file:org.fenixedu.spaces.domain.occupation.config.ExplicitConfigWithSettings.java

License:Open Source License

private static int getNthDayOfWeek(DateTime when) {
    DateTime checkpoint = when;
    int whenDayOfWeek = checkpoint.getDayOfWeek();
    int month = checkpoint.getMonthOfYear();
    checkpoint = checkpoint.withDayOfMonth(1);
    checkpoint = checkpoint.withDayOfWeek(whenDayOfWeek);
    checkpoint = checkpoint.plusWeeks(month - checkpoint.getDayOfMonth());
    int i = 0;//from   w  w w.  jav a2 s . c  o  m
    while (checkpoint.getMonthOfYear() == month && !checkpoint.isEqual(when)) {
        checkpoint = checkpoint.plusWeeks(1);
        i++;
    }
    return i;
}

From source file:org.fenixedu.spaces.domain.occupation.config.MonthlyConfig.java

License:Open Source License

private int getNthDayOfWeek(DateTime when) {
    DateTime checkpoint = when;
    int whenDayOfWeek = checkpoint.getDayOfWeek();
    int month = checkpoint.getMonthOfYear();
    checkpoint = checkpoint.withDayOfMonth(1);
    checkpoint = checkpoint.withDayOfWeek(whenDayOfWeek);
    checkpoint = checkpoint.plusWeeks(month - checkpoint.getDayOfMonth());
    int i = 0;/*from w  ww  . ja  va  2s.c om*/
    while (checkpoint.getMonthOfYear() == month && !checkpoint.isEqual(when)) {
        checkpoint = checkpoint.plusWeeks(1);
        i++;
    }
    return i;
}

From source file:org.fenixedu.spaces.domain.occupation.config.MonthlyConfig.java

License:Open Source License

private DateTime getNextNthdayOfWeek(DateTime when, int nthdayOfTheWeek, int dayOfTheWeek) {
    DateTime checkpoint = when;
    int month = checkpoint.getMonthOfYear();
    checkpoint = checkpoint.withDayOfMonth(1);
    checkpoint = checkpoint.plusWeeks(month - checkpoint.getMonthOfYear());
    int i = nthdayOfTheWeek;
    if (i > 3) {
        DateTime lastDayOfMonth = checkpoint.dayOfMonth().withMaximumValue();
        lastDayOfMonth = lastDayOfMonth.withDayOfWeek(dayOfTheWeek);
        return lastDayOfMonth.plusWeeks(month - lastDayOfMonth.getMonthOfYear());
    } else {/*from  w w w.  ja v  a 2  s .co m*/
        return checkpoint.plusWeeks(nthdayOfTheWeek);
    }
}

From source file:org.fenixedu.treasury.services.integration.erp.ERPExporter.java

License:Open Source License

private XMLGregorianCalendar convertToXMLDateTime(DatatypeFactory dataTypeFactory, DateTime documentDate) {
    return dataTypeFactory.newXMLGregorianCalendar(documentDate.getYear(), documentDate.getMonthOfYear(),
            documentDate.getDayOfMonth(), documentDate.getHourOfDay(), documentDate.getMinuteOfHour(),
            documentDate.getSecondOfMinute(), 0, DatatypeConstants.FIELD_UNDEFINED);
}