Example usage for org.joda.time DateTime getHourOfDay

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

Introduction

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

Prototype

public int getHourOfDay() 

Source Link

Document

Get the hour of day field value.

Usage

From source file:net.sourceforge.fenixedu.domain.EnrolmentEvaluation.java

License:Open Source License

@Override
public void setExamDateYearMonthDay(YearMonthDay evaluationDateYearMonthDay) {
    if (evaluationDateYearMonthDay != null) {
        final Enrolment enrolment = getEnrolment();
        final Thesis thesis = enrolment.getThesis();
        if (thesis != null) {
            DateTime newDateTime = evaluationDateYearMonthDay.toDateTimeAtMidnight();
            final DateTime dateTime = thesis.getDiscussed();
            if (dateTime != null) {
                newDateTime = newDateTime.withHourOfDay(dateTime.getHourOfDay());
                newDateTime = newDateTime.withMinuteOfHour(dateTime.getMinuteOfHour());
            }//w ww .j av a2 s. c o m
            thesis.setDiscussed(newDateTime);
        }
    }
    super.setExamDateYearMonthDay(evaluationDateYearMonthDay);
}

From source file:net.sourceforge.fenixedu.domain.finalDegreeWork.Scheduleing.java

License:Open Source License

public void setStartOfProposalPeriodDateTime(final DateTime dateTime) {
    setStartOfProposalPeriodDateYearMonthDay(dateTime.toYearMonthDay());
    setStartOfProposalPeriodTimeHourMinuteSecond(new HourMinuteSecond(dateTime.getHourOfDay(),
            dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()));
}

From source file:net.sourceforge.fenixedu.domain.finalDegreeWork.Scheduleing.java

License:Open Source License

public void setEndOfProposalPeriodDateTime(final DateTime dateTime) {
    setEndOfProposalPeriodDateYearMonthDay(dateTime.toYearMonthDay());
    setEndOfProposalPeriodTimeHourMinuteSecond(new HourMinuteSecond(dateTime.getHourOfDay(),
            dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()));
}

From source file:net.sourceforge.fenixedu.domain.finalDegreeWork.Scheduleing.java

License:Open Source License

public void setStartOfCandidacyPeriodDateTime(final DateTime dateTime) {
    setStartOfCandidacyPeriodDateYearMonthDay(dateTime.toYearMonthDay());
    setStartOfCandidacyPeriodTimeHourMinuteSecond(new HourMinuteSecond(dateTime.getHourOfDay(),
            dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()));
}

From source file:net.sourceforge.fenixedu.domain.finalDegreeWork.Scheduleing.java

License:Open Source License

public void setEndOfCandidacyPeriodDateTime(final DateTime dateTime) {
    setEndOfCandidacyPeriodDateYearMonthDay(dateTime.toYearMonthDay());
    setEndOfCandidacyPeriodTimeHourMinuteSecond(new HourMinuteSecond(dateTime.getHourOfDay(),
            dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()));
}

From source file:net.sourceforge.fenixedu.domain.onlineTests.StudentTestLog.java

License:Open Source License

public static String getChecksum(DistributedTest distributedTest, Registration student, DateTime dateTime) {
    StringBuilder checksumCode = new StringBuilder();
    checksumCode.append(student.getNumber());
    checksumCode.append(distributedTest.getExternalId());
    final DateTime thisDateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(),
            dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour(),
            dateTime.getSecondOfMinute(), 0);
    checksumCode.append(thisDateTime.getMillis());
    checksumCode.append(Bennu.getInstance().getTestChecksumsSet().iterator().next().getChecksumCode());
    return (Hashing.sha1().hashString(checksumCode.toString(), Charsets.UTF_8)).toString();
}

From source file:net.sourceforge.fenixedu.domain.vigilancy.UnavailablePeriod.java

License:Open Source License

public String getUnavailableAsString() {
    DateTime begin = this.getBeginDate();
    DateTime end = this.getEndDate();

    return String.format("%02d/%02d/%d (%02d:%02d) - %02d/%02d/%d (%02d:%02d): %s", begin.getDayOfMonth(),
            begin.getMonthOfYear(), begin.getYear(), begin.getHourOfDay(), begin.getMinuteOfHour(),
            end.getDayOfMonth(), end.getMonthOfYear(), end.getYear(), end.getHourOfDay(), end.getMinuteOfHour(),
            this.getJustification());
}

From source file:net.sourceforge.fenixedu.presentationTier.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();/*w ww .ja va  2s. c om*/
    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();
    if (photo.getFileInputStream() == 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:net.sourceforge.fenixedu.presentationTier.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 ww.  java  2s.  c om
    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();
    if (photo.getFileInputStream() == 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:net.sourceforge.fenixedu.presentationTier.Action.vigilancy.ConvokeManagement.java

License:Open Source License

public ActionForward confirmConvokes(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    Boolean havingVigilantsThatAreTeachers = false;

    ConvokeBean beanWithTeachers = null;

    if (RenderUtils.getViewState("selectVigilantsThatAreTeachers") != null) {
        beanWithTeachers = (ConvokeBean) RenderUtils.getViewState("selectVigilantsThatAreTeachers")
                .getMetaObject().getObject();
    }/*from w  w  w .  j  a va  2s  .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");
}