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:module.workingCapital.domain.EmailDigesterUtil.java

License:Open Source License

public static void executeTask() {
    final DateTime now = new DateTime();

    I18N.setLocale(new Locale(CoreConfiguration.getConfiguration().defaultLocale()));
    for (Person person : getPeopleToProcess()) {

        final User user = person.getUser();
        if (user.getPerson() != null && user.getExpenditurePerson() != null) {
            Authenticate.mock(user, "System Automation");

            try {
                final LocalizedString applicationTitle = Bennu.getInstance().getConfiguration()
                        .getApplicationSubTitle();
                final String applicationUrl = CoreConfiguration.getConfiguration().applicationUrl();
                final WorkingCapitalYear workingCapitalYear = WorkingCapitalYear.getCurrentYear();
                final LocalDate today = new LocalDate();
                final WorkingCapitalYear previousYear = today.getMonthOfYear() == Month.JANUARY
                        ? WorkingCapitalYear.findOrCreate(today.getYear() - 1)
                        : null;//w w  w .j ava 2s.  co m

                Map<String, List<WorkingCapitalProcessBean>> processesTypeMap = new LinkedHashMap<>();
                if (previousYear == null) {
                    processesTypeMap.put(TAKEN, getMissionProcessBeans(workingCapitalYear.getTaken()));
                    processesTypeMap.put(PENDING_APPROVAL,
                            getMissionProcessBeans(workingCapitalYear.getPendingAproval()));
                    processesTypeMap.put(PENDING_VERIFICATION,
                            getMissionProcessBeans(workingCapitalYear.getPendingVerification()));
                    processesTypeMap.put(PENDING_PROCESSING,
                            getMissionProcessBeans(workingCapitalYear.getPendingProcessing()));
                    processesTypeMap.put(PENDING_AUTHORIZATION,
                            getMissionProcessBeans(workingCapitalYear.getPendingAuthorization()));
                    processesTypeMap.put(PENDING_PAYMENT,
                            getMissionProcessBeans(workingCapitalYear.getPendingPayment()));
                } else {
                    processesTypeMap.put(TAKEN,
                            getMissionProcessBeans(previousYear.getTaken(workingCapitalYear.getTaken())));
                    processesTypeMap.put(PENDING_APPROVAL, getMissionProcessBeans(
                            previousYear.getPendingAproval(workingCapitalYear.getPendingAproval())));
                    processesTypeMap.put(PENDING_VERIFICATION, getMissionProcessBeans(
                            previousYear.getPendingVerification(workingCapitalYear.getPendingVerification())));
                    processesTypeMap.put(PENDING_PROCESSING, getMissionProcessBeans(
                            previousYear.getPendingProcessing(workingCapitalYear.getPendingProcessing())));
                    processesTypeMap.put(PENDING_AUTHORIZATION, getMissionProcessBeans(previousYear
                            .getPendingAuthorization(workingCapitalYear.getPendingAuthorization())));
                    processesTypeMap.put(PENDING_PAYMENT, getMissionProcessBeans(
                            previousYear.getPendingPayment(workingCapitalYear.getPendingPayment())));
                }

                final int totalPending = processesTypeMap.values().stream().map(Collection::size).reduce(0,
                        Integer::sum);

                if (totalPending > 0) {
                    Message.fromSystem().to(Group.users(user)).template("expenditures.capital.pending")
                            .parameter("applicationTitle", applicationTitle)
                            .parameter("applicationUrl", applicationUrl)
                            .parameter("processesByType", processesTypeMap)
                            .parameter("processesTotal", totalPending).and().send();
                }

                for (final WorkingCapital workingCapital : user.getPerson()
                        .getMovementResponsibleWorkingCapitalsSet()) {
                    final Integer year = workingCapital.getWorkingCapitalYear().getYear();
                    if (year.intValue() < now.getYear()
                            || (year.intValue() == now.getYear() && now.getMonthOfYear() == 12)
                                    && now.getDayOfMonth() > 15) {
                        final PresentableProcessState state = workingCapital
                                .getPresentableAcquisitionProcessState();
                        if (state == WorkingCapitalProcessState.WORKING_CAPITAL_AVAILABLE) {
                            Message.fromSystem().to(Group.users(user))
                                    .template("expenditures.capital.pending.termination")
                                    .parameter("applicationTitle", applicationTitle)
                                    .parameter("applicationUrl", applicationUrl)
                                    .parameter("unit", workingCapital.getUnit().getPresentationName())
                                    .parameter("year", workingCapital.getWorkingCapitalYear().getYear()).and()
                                    .send();
                        }
                    }
                }
            } finally {
                Authenticate.unmock();
            }
        }
    }
}

From source file:nbm.center.catalog.CatalogXmlFactory.java

License:Apache License

private String makeCatalogTimestampFrom(DateTime today) {
    String catalogTimestamp = "";
    catalogTimestamp += "00" + "/";
    catalogTimestamp += today.getMinuteOfHour() + "/";
    catalogTimestamp += today.getHourOfDay() + "/";
    catalogTimestamp += today.getDayOfMonth() + "/";
    catalogTimestamp += today.getMonthOfYear() + "/";
    catalogTimestamp += today.getYear();
    return catalogTimestamp;
}

From source file:nc.noumea.mairie.organigramme.core.utility.DateUtil.java

License:Open Source License

/**
 * Retoure une reprsentation de la date/* w  ww  . j  ava2  s .  co  m*/
 * @param date date concerne
 * @return exemple : "7 janvier 2014", "" si la date en entre est null
 */
public static String formatDateAvecMoisEnTexte(Date date) {
    if (date == null) {
        return "";
    }
    DateTime dateTime = new DateTime(date);
    return dateTime.getDayOfMonth() + " " + libelleMois(dateTime.getMonthOfYear()) + " " + dateTime.getYear();
}

From source file:net.naijatek.myalumni.modules.admin.presentation.action.MaintainSystemModuleAction.java

License:Open Source License

/**
 * /*w w w .  jav a2  s .  com*/
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward databaseBackup(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    if (!adminSecurityCheck(request)) {
        return mapping.findForward(BaseConstants.FWD_ADMIN_LOGIN);
    }
    ActionMessages msgs = new ActionMessages();
    DateTime dtime = new DateTime(new Date());
    String dateStr = dtime.getMonthOfYear() + "_" + dtime.getDayOfMonth() + "_" + dtime.getYear() + "_"
            + dtime.getHourOfDay() + "_" + dtime.getMinuteOfHour() + "_" + dtime.getSecondOfMinute();

    try {
        sysService.systemDatabaseBackup(getSysProp().getValue("BACKUP.FILEPATH") + dateStr + ".sql");
    } catch (MyAlumniBaseException ex) {
        msgs.add(BaseConstants.ERROR_KEY, new ActionMessage(ex.getMessage()));
        saveMessages(request, msgs);
        return mapping.getInputForward();
    }

    msgs.add(BaseConstants.INFO_KEY, new ActionMessage("message.backupsuccessful", dateStr + ".sql"));
    saveMessages(request, msgs);

    listDatabaseBackupHelper(request);
    return mapping.findForward(BaseConstants.FWD_SUCCESS);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.person.vigilancy.ChangeConvokeActive.java

License:Open Source License

private static void sendEmailNotification(Boolean bool, Person person, Vigilancy convoke) {

    String replyTo = person.getEmail();

    VigilantGroup group = convoke.getAssociatedVigilantGroup();
    String groupEmail = group.getContactEmail();

    if (groupEmail != null) {
        if (person.isExamCoordinatorForVigilantGroup(group)) {
            replyTo = groupEmail;/*from   w w w  .j  a v  a 2 s. co m*/
        }
    }

    WrittenEvaluation writtenEvaluation = convoke.getWrittenEvaluation();

    String emailMessage = generateMessage(bool, convoke);
    DateTime date = writtenEvaluation.getBeginningDateTime();
    String time = writtenEvaluation.getBeginningDateHourMinuteSecond().toString();
    String beginDateString = date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear();

    String subject = BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.subject",
            new String[] { writtenEvaluation.getName(), group.getName(), beginDateString, time });

    new Message(PersonSender.newInstance(person), new ConcreteReplyTo(replyTo).asCollection(),
            new Recipient(VigilancyGroup.get(convoke)).asCollection(), Collections.EMPTY_LIST,
            Collections.EMPTY_LIST, subject, emailMessage, convoke.getSitesAndGroupEmails());

}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.person.vigilancy.ChangeConvokeActive.java

License:Open Source License

private static String generateMessage(Boolean bool, Vigilancy convoke) {

    WrittenEvaluation writtenEvaluation = convoke.getWrittenEvaluation();
    DateTime beginDate = writtenEvaluation.getBeginningDateTime();
    String date = beginDate.getDayOfMonth() + "-" + beginDate.getMonthOfYear() + "-" + beginDate.getYear();

    return BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.active.body",
            new String[] { convoke.getVigilantWrapper().getPerson().getName(),
                    (bool) ? BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.convokedAgain")
                            : BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.uncovoked"),
                    writtenEvaluation.getFullName(), date,
                    writtenEvaluation.getBeginningDateHourMinuteSecond().toString() });
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.person.vigilancy.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());
        }//  ww  w.  java 2 s .  c  om

        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(Bundle.VIGILANCY, "email.convoke.subject", new String[] {
                group.getEmailSubjectPrefix(), writtenEvaluation.getName(), group.getName(), beginDateString });

        new Message(PersonSender.newInstance(person), new ConcreteReplyTo(replyTo).asCollection(),
                new Recipient(UserGroup.of(Person.convertToUsers(recievers))).asCollection(),
                Collections.EMPTY_LIST, Collections.EMPTY_LIST, subject, emailMessage, bccs);
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.person.vigilancy.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   ww w.  j  a v a2s  .c  o m*/
        String message = BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.unavailablePeriod",
                new String[] { person.getName(), beginDate, endDate, justification });

        String subject = BundleUtil.getString(Bundle.VIGILANCY, "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:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.exams.DeleteWrittenEvaluation.java

License:Open Source License

private void notifyVigilants(WrittenEvaluation writtenEvaluation) {

    final Set<Person> tos = new HashSet<Person>();

    for (VigilantGroup group : writtenEvaluation.getAssociatedVigilantGroups()) {
        tos.clear();/*from w w  w  .j  a  va2 s. c om*/
        DateTime date = writtenEvaluation.getBeginningDateTime();
        String time = writtenEvaluation.getBeginningDateHourMinuteSecond().toString();
        String beginDateString = date.getDayOfMonth() + "-" + date.getMonthOfYear() + "-" + date.getYear();

        String subject = BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.subject",
                new String[] { writtenEvaluation.getName(), group.getName(), beginDateString, time });
        String body = BundleUtil.getString(Bundle.VIGILANCY, "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:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.exams.EditWrittenEvaluation.java

License:Open Source License

private void notifyVigilants(WrittenEvaluation writtenEvaluation, Date dayDate, Date beginDate) {

    final HashSet<Person> tos = new HashSet<Person>();

    // VigilantGroup group =
    // writtenEvaluation.getAssociatedVigilantGroups().iterator().next();
    for (VigilantGroup group : writtenEvaluation.getAssociatedVigilantGroups()) {
        tos.clear();/*from ww w .  java2 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(UserGroup.of(Person.convertToUsers(tos))).asCollection(), subject, body, "");
    }
}