Example usage for java.util Calendar HOUR

List of usage examples for java.util Calendar HOUR

Introduction

In this page you can find the example usage for java.util Calendar HOUR.

Prototype

int HOUR

To view the source code for java.util Calendar HOUR.

Click Source Link

Document

Field number for get and set indicating the hour of the morning or afternoon.

Usage

From source file:com.l2jfree.gameserver.model.olympiad.Olympiad.java

protected void setNewOlympiadEnd() {
    SystemMessage sm = new SystemMessage(SystemMessageId.OLYMPIAD_PERIOD_S1_HAS_STARTED);
    sm.addNumber(_currentCycle);/*from w  ww  . j  ava2 s.  c o m*/

    Announcements.getInstance().announceToAll(sm);

    Calendar currentTime = Calendar.getInstance();
    currentTime.add(Calendar.MONTH, 1);
    currentTime.set(Calendar.DAY_OF_MONTH, 1);
    currentTime.set(Calendar.AM_PM, Calendar.AM);
    currentTime.set(Calendar.HOUR, 12);
    currentTime.set(Calendar.MINUTE, 0);
    currentTime.set(Calendar.SECOND, 0);
    _olympiadEnd = currentTime.getTimeInMillis();

    Calendar nextChange = Calendar.getInstance();
    _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
    scheduleWeeklyChange();
}

From source file:com.concursive.connect.web.modules.calendar.utils.CalendarView.java

/**
 * Gets the Today attribute of the CalendarView object
 *
 * @return The Today value//from  w  ww.j  a  v  a2s  .  c om
 */
public String getToday() {
    Calendar today = Calendar.getInstance(locale);
    today.set(Calendar.HOUR, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);
    if (timeZone != null) {
        today.setTimeZone(timeZone);
    }
    if (locale != null) {
        SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.LONG,
                locale);
        return formatter.format(today.getTime());
    } else {
        return (this.getMonthName(today) + " " + today.get(Calendar.DAY_OF_MONTH) + ", "
                + today.get(Calendar.YEAR));
    }
}

From source file:org.openmeetings.app.data.calendar.daos.AppointmentDaoImpl.java

/**
 * @author becherer//from w  ww.j  av a  2 s  . c  o m
 * @param userId
 * @return
 */
public List<Appointment> getTodaysAppointmentsbyRangeAndMember(Long userId) {
    log.debug("getAppoitmentbyRangeAndMember : UserID - " + userId);

    //this query returns duplicates if the user books an appointment with
    //his own user as second meeting-member, swagner 19.02.2012

    String hql = "SELECT app from MeetingMember mm " + "JOIN mm.appointment as app "
            + "WHERE mm.userid.user_id= :userId " + "AND mm.deleted <> :mm_deleted "
            + "AND app.deleted <> :app_deleted " + "AND  " + "app.appointmentStarttime between :starttime "
            + "AND " + " :endtime";

    TimeZone timeZone = timezoneUtil.getTimezoneByUser(usersDao.getUser(userId));

    Calendar startCal = Calendar.getInstance(timeZone);
    startCal.set(Calendar.MINUTE, 0);
    startCal.set(Calendar.HOUR, 0);
    startCal.set(Calendar.SECOND, 1);

    Calendar endCal = Calendar.getInstance(timeZone);
    endCal.set(Calendar.MINUTE, 23);
    endCal.set(Calendar.HOUR, 59);
    endCal.set(Calendar.SECOND, 59);

    try {
        TypedQuery<Appointment> query = em.createQuery(hql, Appointment.class);

        query.setParameter("mm_deleted", true);
        query.setParameter("app_deleted", "true");
        query.setParameter("userId", userId);

        query.setParameter("starttime", startCal.getTime());
        query.setParameter("endtime", endCal.getTime());

        List<Appointment> listAppoints = query.getResultList();
        return listAppoints;
    } catch (Exception e) {
        log.error("Error in getTodaysAppoitmentsbyRangeAndMember : ", e);
        return null;
    }
}

From source file:ezbake.data.elastic.ElasticClientTest.java

@Test
public void testRangeDateFacets() throws Exception {
    final SimpleDateFormat dtg = new SimpleDateFormat(EzElasticTestUtils.DATE_FORMAT);
    Calendar calendar = new GregorianCalendar();

    calendar.add(Calendar.DAY_OF_YEAR, -1);
    long last24Time = DateUtils.round(calendar, Calendar.HOUR).getTimeInMillis();

    calendar.add(Calendar.DAY_OF_YEAR, -1);
    long last48Time = DateUtils.round(calendar, Calendar.HOUR).getTimeInMillis();

    calendar.add(Calendar.DAY_OF_YEAR, -1);
    long last72Time = DateUtils.round(calendar, Calendar.HOUR).getTimeInMillis();

    List<Facet> rangeDateFacets = Collections
            .singletonList(EzElasticTestUtils.generateDateBucketFacet(last24Time, last48Time, last72Time));

    final SearchResult results = client.get(QueryBuilders.matchAllQuery().toString(), TEST_TYPE, null, null,
            rangeDateFacets, null, 0, (short) 10, null, COMMON_USER_TOKEN);

    assertEquals(4, results.getTotalHits());
    assertFalse(results.getFacets().isEmpty());
    assertTrue(results.getFacets().containsKey("Report Date"));
    final FacetResult facetResult = results.getFacets().get("Report Date");
    for (final RangeFacetEntry entry : facetResult.getRangeFacetResult().getEntries()) {
        if (dtg.parse(entry.getRangeFrom()).getTime() >= last24Time
                || dtg.parse(entry.getRangeFrom()).getTime() >= last48Time
                || dtg.parse(entry.getRangeFrom()).getTime() >= last72Time) {
            assertEquals(3, entry.getCount());
        } else {//from   w ww  .  j  a  va 2  s  . c o  m
            assertEquals(4, entry.getCount());
        }
    }
}

From source file:org.openmrs.module.orderextension.web.controller.OrderExtensionOrderController.java

private Date adjustDateToEndOfDay(Date dateToAdjust) {
    if (dateToAdjust != null) {
        Calendar adjusted = Calendar.getInstance();
        adjusted.setTime(dateToAdjust);/*from  w  w w  .  ja  v a 2s . co  m*/
        adjusted.set(Calendar.HOUR, 23);
        adjusted.set(Calendar.MINUTE, 59);

        return adjusted.getTime();
    }
    return dateToAdjust;
}

From source file:alfio.controller.api.admin.EventApiController.java

@RequestMapping(value = "/events/{eventName}/ticket-sold-statistics", method = GET)
public List<TicketSoldStatistic> getTicketSoldStatistics(@PathVariable("eventName") String eventName,
        @RequestParam(value = "from", required = false) String f,
        @RequestParam(value = "to", required = false) String t, Principal principal) throws ParseException {
    Event event = loadEvent(eventName, principal);
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    //TODO: cleanup
    Date from = DateUtils.truncate(f == null ? new Date(0) : format.parse(f), Calendar.HOUR);
    Date to = DateUtils/*from   w w  w. java2  s. co m*/
            .addMilliseconds(DateUtils.ceiling(t == null ? new Date() : format.parse(t), Calendar.DATE), -1);
    //

    return eventStatisticsManager.getTicketSoldStatistics(event.getId(), from, to);
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

private void addDomainGridLinesToPlot(int hourInterval, XYPlot plot) {
    DateAxis axis = (DateAxis) plot.getDomainAxis();

    Calendar currDate = Calendar.getInstance();
    currDate.setTime(axis.getMinimumDate());

    Calendar maxDate = Calendar.getInstance();
    maxDate.setTime(axis.getMaximumDate());

    // we do not paint the first domain grid lines since it conflicts with
    // the axis line
    boolean first = true;
    while (currDate.compareTo(maxDate) < 0) {
        if (first) {
            first = false;//from   w  w w  . jav  a 2 s .  c o  m
        } else {
            paintDomainGridLine(currDate, plot);
        }
        currDate.add(Calendar.HOUR, hourInterval);
    }
}

From source file:com.square.core.service.implementations.ActionServiceImplementation.java

@Override
public ActionResultatDto modifierAction(ActionModificationDto actionModificationDto) {
    // Dto null/*w  w w  .  java2 s .  co m*/
    if (actionModificationDto == null) {
        throw new BusinessException(messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DTO_NULL));
    }

    // Identifiant de l'action null
    if (actionModificationDto.getIdAction() == null) {
        throw new BusinessException(messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_IDACTION_NULL));
    }

    // Rcupration de l'action correspondant
    final Action actionAModifier = actionDao.rechercherActionParId(actionModificationDto.getIdAction());
    if (actionAModifier == null) {
        throw new BusinessException(messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_INEXISTANTE));
    }
    if (logger.isDebugEnabled()) {
        logger.debug("bug 0008864 : modifierAction(ActionModificationDto)");
        logger.debug("recuperation de l'action : " + actionModificationDto.getIdAction());
        logger.debug("dateCreation = " + (actionAModifier.getDateCreation() != null
                ? SDF.format(actionAModifier.getDateCreation().getTime())
                : "null"));
    }

    Agence agence = null;
    if (actionModificationDto.getAgence() != null
            && actionModificationDto.getAgence().getIdentifiant() != null) {
        agence = agenceDao.rechercheAgenceParId(actionModificationDto.getAgence().getIdentifiant());
        if (agence == null) {
            logger.error(
                    "L'agence id = " + actionModificationDto.getAgence().getIdentifiant() + "n'existe pas.");
            throw new TechnicalException(
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_AGENCE_INEXISTANTE));
        }
    }

    // Rcupration de la ressource correspondant au commercial (on permet dsormais le changement de ressource mme si existant)
    Ressource commercial = null;
    if (actionAModifier.getActionAttribution() != null && actionModificationDto.getRessource() != null
            && actionModificationDto.getRessource().getIdentifiant() != null) {
        commercial = ressourceDao
                .rechercherRessourceParId(actionModificationDto.getRessource().getIdentifiant());
        if (commercial == null) {
            logger.error(
                    "La ressource " + actionModificationDto.getRessource().getIdentifiant() + " n'existe pas");
            throw new BusinessException(
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_COMMERCIAL_INEXISTANTE));
        }
    }

    // Rcupration de la dure
    ActionDuree dureeAction = null;
    if (actionModificationDto.getIdDuree() != null) {
        dureeAction = actionDureeDao.rechercherDureeActionParId(actionModificationDto.getIdDuree());
        if (dureeAction == null) {
            throw new BusinessException(
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DUREE_INEXISTANTE));
        }
    }

    final RapportDto rapport = new RapportDto();

    // Vrification de la nature
    if (actionModificationDto.getNatureAction() == null
            || actionModificationDto.getNatureAction().getIdentifiant() == null) {
        rapport.ajoutRapport(ActionModificationDto.class.getSimpleName() + ".nature",
                messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_ACTION_NULL), true);
    }

    // Pour une action de nature "tlphone sortant" passant au statut "termin"
    if (actionModificationDto.getNatureAction() != null
            && squareMappingService.getIdNatureActionTelephoneSortant()
                    .equals(actionModificationDto.getNatureAction().getIdentifiant())
            && actionModificationDto.getStatut() != null && squareMappingService.getIdStatutActionTermine()
                    .equals(actionModificationDto.getStatut().getIdentifiant())) {
        // On vrifie que le rsultat de la nature est renseign
        if (actionModificationDto.getNatureResultat() == null
                || actionModificationDto.getNatureResultat().getIdentifiant() == null) {
            rapport.ajoutRapport(ActionModificationDto.class.getSimpleName() + ".natureResultat",
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_RESULTAT_ACTION_NULL),
                    true);
        }
    }

    // vrification que la nature de resultat est selectionne pour la nature d'action visite sortante si on demande la vrification
    if (!BooleanUtils.isFalse(actionModificationDto.getVerifierResultatNatureAction())
            && actionModificationDto.getNatureAction() != null
            && squareMappingService.getIdNatureActionVisiteSortante()
                    .equals(actionModificationDto.getNatureAction().getIdentifiant())
            && actionModificationDto.getNatureResultat() == null && squareMappingService
                    .getIdStatutActionTermine().equals(actionModificationDto.getStatut().getIdentifiant())) {
        throw new BusinessException(
                messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_RESULTAT_VISITE_SORTANTE));
    }

    // Contrle du statut
    final ValidationExpressionProp[] propsAction = new ValidationExpressionProp[] {
            new ValidationExpressionProp("statut", null,
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_STATUT_NULL)),
            new ValidationExpressionProp("dateAction", null,
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DATE_ACTION_NULL)) };

    validationExpressionUtil.verifierSiVide(rapport, actionModificationDto, propsAction);

    if (actionModificationDto.getDateAction() != null) {
        // On copie la date de l'action enregistre en base
        final Calendar ancienneDateAction = DateUtils.truncate((Calendar) actionAModifier.getDate().clone(),
                Calendar.HOUR);
        // On copie la nouvelle date d'action
        final Calendar nouvelleDateAction = DateUtils
                .truncate((Calendar) actionModificationDto.getDateAction().clone(), Calendar.HOUR);
        // Si la date de l'action est modifie
        if (!ancienneDateAction.equals(nouvelleDateAction)) {
            // On vrifie que la date d'action est postrieure  la date courante
            if (DateUtils.truncate(nouvelleDateAction, Calendar.DAY_OF_MONTH)
                    .before(DateUtils.truncate(Calendar.getInstance(), Calendar.DAY_OF_MONTH))) {
                rapport.ajoutRapport(actionModificationDto.getClass().getSimpleName() + ".dateAction",
                        messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_DATE_ACTION_INVALIDE), true);
            }
        }
    }

    // Une action ne peut tre termine sans tre attribue
    if (actionModificationDto.getStatut() != null
            && squareMappingService.getIdStatutActionTermine()
                    .equals(actionModificationDto.getStatut().getIdentifiant())
            && (actionModificationDto.getRessource() == null
                    || actionModificationDto.getRessource().getIdentifiant() == null)) {
        rapport.ajoutRapport(ActionModificationDto.class.getSimpleName() + ".statut",
                messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_TERMINEE_SANS_ATTRIBUTION), true);
    }

    // On ne peut rendre visible une action dans l'agenda que si elle a une date de dbut, une dure
    if (actionModificationDto.getVisibleAgenda() != null
            && actionModificationDto.getVisibleAgenda().booleanValue()
            && (actionModificationDto.getDateAction() == null || actionModificationDto.getIdDuree() == null)) {
        rapport.ajoutRapport(actionModificationDto.getClass().getSimpleName() + ".isVisibleAgenda",
                messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_IMPOSSIBLE_VISIBLE_AGENDA), true);
    }

    // Prsence d'erreurs empchant la modification de l'action
    if (rapport.getEnErreur()) {
        // On retourne le rapport d'erreur
        RapportUtil.logRapport(rapport, logger);
        throw new ControleIntegriteException(rapport);
    }

    // Vrification de l'existance des nouveaux champs
    verificationExistanceModification(actionModificationDto, actionAModifier);

    // Vrification de la rgle de gestion de l'opportunit en cours
    if (Boolean.TRUE.equals(actionModificationDto.getVerifierRegleGestionOpportuniteEnCours())) {
        verifierRegleGestionOpportuniteOuverte(actionModificationDto, actionAModifier);
    }

    // Modification de l'action
    if (actionModificationDto.getNatureAction() != null
            && actionModificationDto.getNatureAction().getIdentifiant() != null) {
        final ActionNature nature = actionNatureDao
                .rechercherNatureActionParId(actionModificationDto.getNatureAction().getIdentifiant());
        if (nature == null) {
            throw new TechnicalException(
                    messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_ACTION_NATURE_ACTION_INEXISTANT));
        }
        actionAModifier.setNature(nature);
    }
    // modification du type d'action
    final IdentifiantLibelleDto typeAction = actionModificationDto.getTypeAction();
    if (actionModificationDto.getTypeAction() != null && typeAction.getIdentifiant() != null) {
        actionAModifier.setType(actionTypeDao.rechercherTypeActionParId(typeAction.getIdentifiant()));
    }

    // modificatio de l'objet d'action
    final IdentifiantLibelleDto objetAction = actionModificationDto.getObjetAction();
    if (actionModificationDto.getObjetAction() != null && objetAction.getIdentifiant() != null) {
        actionAModifier.setObjet(actionObjetDao.rechercherObjetActionParId(objetAction.getIdentifiant()));
    }
    // affectation au pot commun
    if (actionModificationDto.getAffectationPotCommun() != null
            && actionModificationDto.getAffectationPotCommun()) {
        actionAModifier.getActionAttribution()
                .setAgence(agenceDao.rechercheAgenceParId(squareMappingService.getIdentifiantAgenceFrance()));
        actionAModifier.getActionAttribution().setRessource(null);
    }
    if (actionModificationDto.getRappelMail() != null) {
        actionAModifier.setMailNotification(actionModificationDto.getRappelMail());
    }
    // action tlphone sortant ou visite sortante
    if (actionModificationDto.getNatureAction() != null
            && (squareMappingService.getIdNatureActionTelephoneSortant()
                    .equals(actionModificationDto.getNatureAction().getIdentifiant())
                    || squareMappingService.getIdNatureActionVisiteSortante()
                            .equals(actionModificationDto.getNatureAction().getIdentifiant()))) {
        if (actionModificationDto.getNatureResultat() != null
                && actionModificationDto.getNatureResultat().getIdentifiant() != null) {
            actionAModifier.setNatureResultat(actionNatureResultatDao.rechercherNatureResultatActionById(
                    actionModificationDto.getNatureResultat().getIdentifiant()));
        } else {
            actionAModifier.setNatureResultat(null);
        }
    }

    if (agence != null) {
        // si on affecte une action de relance (qui n'avait pas d'agence)  une agence, on affecte aussi l'opp  l'agence
        if (actionAModifier.getActionAttribution().getAgence() == null
                && actionAModifier.getType().getId().equals(squareMappingService.getIdTypeActionRelance())
                && actionAModifier.getActionAffectation().getOpportunite() != null) {
            actionAModifier.getActionAffectation().getOpportunite().getOpportuniteAttribution()
                    .setAgence(agence);
        }
        actionAModifier.getActionAttribution().setAgence(agence);
    }

    if (commercial != null) {
        // si on affecte une action de relance (qui n'avait pas de ressource)  une ressource, on affecte aussi l'opp  la ressource
        if (actionAModifier.getActionAttribution().getRessource() == null
                && actionAModifier.getType().getId().equals(squareMappingService.getIdTypeActionRelance())
                && actionAModifier.getActionAffectation().getOpportunite() != null) {
            actionAModifier.getActionAffectation().getOpportunite().getOpportuniteAttribution()
                    .setRessource(commercial);
        }
        actionAModifier.getActionAttribution().setRessource(commercial);
    }

    final Long idStatutTermine = squareMappingService.getIdStatutTerminer();

    // Rsultat
    // Cration d'une opportunit si le rsultat passe  opportunit
    OpportuniteDto opportuniteCree = null;
    if (actionAModifier.getResultat() == null) {
        if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat().getIdentifiant()
                .equals(squareMappingService.getIdResultatOpportunite())) {
            actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine));
            opportuniteCree = creationOpportunite(actionAModifier);
        } else if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat()
                .getIdentifiant().equals(squareMappingService.getIdResultatRelance())) {
            actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine));
        } else {
            actionAModifier.setStatut(actionStatutDao
                    .rechercherStatutActionParId(actionModificationDto.getStatut().getIdentifiant()));
        }
        if (actionModificationDto.getResultat() != null) {
            actionAModifier.setResultat(actionResultatDao
                    .rechercherActionResultatParId(actionModificationDto.getResultat().getIdentifiant()));
        }
    } else {
        if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat().getIdentifiant()
                .equals(squareMappingService.getIdResultatOpportunite())) {
            if (!actionAModifier.getResultat().getId()
                    .equals(squareMappingService.getIdResultatOpportunite())) {
                actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine));
                opportuniteCree = creationOpportunite(actionAModifier);
            }
        } else if (actionModificationDto.getResultat() != null && actionModificationDto.getResultat()
                .getIdentifiant().equals(squareMappingService.getIdResultatRelance())) {
            actionAModifier.setStatut(actionStatutDao.rechercherStatutActionParId(idStatutTermine));
        } else {
            actionAModifier.setStatut(actionStatutDao
                    .rechercherStatutActionParId(actionModificationDto.getStatut().getIdentifiant()));
        }
        if (actionModificationDto.getResultat() != null) {
            actionAModifier.setResultat(actionResultatDao
                    .rechercherActionResultatParId(actionModificationDto.getResultat().getIdentifiant()));
        }
    }

    // Mise  jour de la date de l'action
    if (idStatutTermine.equals(actionModificationDto.getStatut().getIdentifiant())) {
        // Si l'action passe au statut "termin", on met  jour la date termine de l'action en prenant la date courante
        actionAModifier.setDateTerminee(Calendar.getInstance());
    } else {
        actionAModifier.setDate(actionModificationDto.getDateAction());
    }

    // Priorit
    if (actionModificationDto.getPriorite() != null
            && actionModificationDto.getPriorite().getIdentifiant() != null) {
        // Rcupration de la priorit
        final ActionPriorite priorite = actionPrioriteDao
                .rechercherPrioriteActionParId(actionModificationDto.getPriorite().getIdentifiant());
        if (priorite != null) {
            actionAModifier.setPriorite(priorite);
        }
    }

    // Dure de l'action
    if (dureeAction != null) {
        actionAModifier.setDuree(dureeAction);
    }

    // Action visible ou non dans l'agenda
    actionAModifier.setVisibleAgenda(actionModificationDto.getVisibleAgenda() != null
            && actionModificationDto.getVisibleAgenda().booleanValue());

    // Construction de la date de notification
    if (actionModificationDto.getRappel() != null && actionModificationDto.getRappel()) {
        if (actionModificationDto.getIdNotification() != null) {
            final ActionNotificationInfosDto notification = squareMappingService
                    .getActionNotificationParId(actionModificationDto.getIdNotification());
            final Calendar soustraction = Calendar.getInstance();
            soustraction.clear();
            final Long dateTime = -notification.getNotification().getTimeInMillis()
                    + actionAModifier.getDate().getTimeInMillis();
            soustraction.setTimeInMillis(dateTime);
            actionAModifier.setDateNotification(soustraction);
        } else {
            actionAModifier.setDateNotification(null);
        }
    } else {
        actionAModifier.setDateNotification(null);
    }
    // Constuction du commentaire
    if (actionModificationDto.getCommentaire() != null) {
        final Commentaire commentaire = mapperDozerBean.map(actionModificationDto.getCommentaire(),
                Commentaire.class);
        if (actionModificationDto.getCommentaire().getRessource() != null) {
            final Ressource ressource = ressourceDao
                    .rechercherRessourceParId(actionModificationDto.getCommentaire().getRessource().getId());
            commentaire.setRessource(ressource);
        }
        if (actionAModifier.getCommentaires() == null) {
            final List<Commentaire> list = new ArrayList<Commentaire>();
            list.add(commentaire);
            actionAModifier.setCommentaires(list);
        } else {
            actionAModifier.getCommentaires().add(commentaire);
        }
    }

    // Envoi d'un email si demand
    if (actionAModifier.isMailNotification()
            && squareMappingService.getIdStatutActionTermine().equals(actionAModifier.getStatut().getId())) {
        if (actionAModifier.getRessource() != null) {
            final Ressource createur = actionAModifier.getRessource();
            if (createur.getEmail() == null || "".equals(createur.getEmail())) {
                throw new BusinessException(
                        messageSourceUtil.get(ActionKeyUtil.MESSAGE_ERREUR_EMAIL_CREATEUR_ACTION_VIDE));
            }
            final List<String> listeDestinataires = new ArrayList<String>();
            listeDestinataires.add(createur.getEmail());
            final String titre = messageSourceUtil.get(ActionKeyUtil.TITRE_EMAIL_FIN_ACTION);
            String personneAction = "";
            String type = "";
            String objet = "";
            String sousObjet = "";
            String nature = "";
            String campagne = "";
            if (actionAModifier.getActionAffectation() != null
                    && actionAModifier.getActionAffectation().getPersonne() != null) {
                final Personne personne = actionAModifier.getActionAffectation().getPersonne();
                if (personne instanceof PersonnePhysique) {
                    final PersonnePhysique personnePhysique = (PersonnePhysique) actionAModifier
                            .getActionAffectation().getPersonne();
                    personneAction = personnePhysique.getNom() + ESPACE + personnePhysique.getPrenom();
                } else if (personne instanceof PersonneMorale) {
                    final PersonneMorale personneMorale = (PersonneMorale) actionAModifier
                            .getActionAffectation().getPersonne();
                    personneAction = personneMorale.getRaisonSociale();
                }
            }
            if (actionAModifier.getType() != null) {
                type = actionAModifier.getType().getLibelle();
            }
            if (actionAModifier.getObjet() != null) {
                objet = actionAModifier.getObjet().getLibelle();
            }
            if (actionAModifier.getSousObjet() != null) {
                sousObjet = actionAModifier.getSousObjet().getLibelle();
            }
            if (actionAModifier.getNature() != null) {
                nature = actionAModifier.getNature().getLibelle();
            }
            if (actionAModifier.getCampagne() != null) {
                campagne = actionAModifier.getCampagne().getLibelle();
            }
            final String message = messageSourceUtil.get(ActionKeyUtil.MESSAGE_EMAIL_FIN_ACTION,
                    new String[] { personneAction, type, objet, sousObjet, nature, campagne });
            final MailDto mailDto = new MailDto(expediteurNoReply, listeDestinataires, titre, message, null,
                    false);
            emailSquarePlugin.envoyerEmail(mailDto);
        }
    }
    // Renseignement de la date de modification
    actionAModifier.setDateModification(Calendar.getInstance());

    final ActionResultatDto resultat = new ActionResultatDto();
    if (opportuniteCree != null) {
        resultat.setIdOpportunite(opportuniteCree.getIdOpportunite());
    }
    return resultat;
}

From source file:com.icesoft.faces.component.selectinputdate.SelectInputDateRenderer.java

public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    validateParameters(facesContext, uiComponent, SelectInputDate.class);
    DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent);
    SelectInputDate selectInputDate = (SelectInputDate) uiComponent;

    Date value;/*from  w w  w  .  j a va 2 s.c  o m*/
    boolean actuallyHaveTime = false;
    if (selectInputDate.isNavEvent()) {
        if (log.isTraceEnabled()) {
            log.trace("Rendering Nav Event");
        }
        value = selectInputDate.getNavDate();
        //System.out.println("navDate: " + value);
    } else if (selectInputDate.isRenderAsPopup() && !selectInputDate.isEnterKeyPressed(facesContext)) {
        value = selectInputDate.getPopupDate();
        if (value != null) {
            actuallyHaveTime = true;
        }
    } else {
        if (log.isTraceEnabled()) {
            log.trace("Logging non nav event");
        }
        value = CustomComponentUtils.getDateValue(selectInputDate);
        if (value != null) {
            actuallyHaveTime = true;
        }
        //System.out.println("CustomComponentUtils.getDateValue: " + value);
    }

    DateTimeConverter converter = selectInputDate.resolveDateTimeConverter(facesContext);
    TimeZone tz = selectInputDate.resolveTimeZone(facesContext);
    Locale currentLocale = selectInputDate.resolveLocale(facesContext);
    DateFormatSymbols symbols = new DateFormatSymbols(currentLocale);

    //System.out.println("SIDR.encodeEnd()  timezone: " + tz);
    //System.out.println("SIDR.encodeEnd()  locale: " + currentLocale);

    Calendar timeKeeper = Calendar.getInstance(tz, currentLocale);
    timeKeeper.setTime(value != null ? value : new Date());

    // get the parentForm
    UIComponent parentForm = findForm(selectInputDate);
    // if there is no parent form - ERROR
    if (parentForm == null) {
        log.error("SelectInputDate::must be in a FORM");
        return;
    }
    String clientId;
    if (!domContext.isInitialized()) {
        Element root = domContext.createRootElement(HTML.DIV_ELEM);
        boolean popupState = selectInputDate.isShowPopup();

        clientId = uiComponent.getClientId(facesContext);
        if (uiComponent.getId() != null)
            root.setAttribute("id", clientId + ROOT_DIV);

        Element table = domContext.createElement(HTML.TABLE_ELEM);
        if (selectInputDate.isRenderAsPopup()) {
            if (log.isTraceEnabled()) {
                log.trace("Render as popup");
            }
            // ICE-2492
            root.setAttribute(HTML.CLASS_ATTR,
                    Util.getQualifiedStyleClass(uiComponent, CSS_DEFAULT.DEFAULT_CALENDARPOPUP_CLASS, false));
            Element dateText = domContext.createElement(HTML.INPUT_ELEM);
            //System.out.println("value: " + selectInputDate.getValue());

            dateText.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT); // ICE-2302
            dateText.setAttribute(HTML.VALUE_ATTR, selectInputDate.getTextToRender());
            dateText.setAttribute(HTML.ID_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT);
            dateText.setAttribute(HTML.NAME_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT);
            dateText.setAttribute(HTML.CLASS_ATTR, selectInputDate.getCalendarInputClass());
            dateText.setAttribute(HTML.ONFOCUS_ATTR, "setFocus('');");
            dateText.setAttribute("onkeypress", this.ICESUBMIT);
            boolean withinSingleSubmit = org.icefaces.impl.util.Util.withinSingleSubmit(selectInputDate);
            if (withinSingleSubmit) {
                JavascriptContext.addJavascriptCall(facesContext,
                        "ice.cancelSingleSubmit('" + clientId + ROOT_DIV + "');");
            }
            String singleSubmitCall = "ice.fullSubmit('@this', '@all', event, this, function(p) { p('ice.submit.type', 'ice.se'); p('ice.submit.serialization', 'form');});";
            String onblur = combinedPassThru("setFocus('');",
                    selectInputDate.getPartialSubmit() ? ICESUBMITPARTIAL
                            : withinSingleSubmit ? singleSubmitCall : null);
            dateText.setAttribute(HTML.ONBLUR_ATTR, onblur);
            if (selectInputDate.getTabindex() != null) {
                dateText.setAttribute(HTML.TABINDEX_ATTR, selectInputDate.getTabindex());
            }
            if (selectInputDate.getAutocomplete() != null
                    && "off".equalsIgnoreCase(selectInputDate.getAutocomplete())) {
                dateText.setAttribute(HTML.AUTOCOMPLETE_ATTR, "off");
            }
            String tooltip = null;
            tooltip = selectInputDate.getInputTitle();
            if (tooltip == null || tooltip.length() == 0) {
                // extract the popupdate format and use it as a tooltip
                tooltip = getMessageWithParamFromResource(facesContext, INPUT_TEXT_TITLE,
                        selectInputDate.getSpecifiedPopupDateFormat());
            }
            if (tooltip != null && tooltip.length() > 0) {
                dateText.setAttribute(HTML.TITLE_ATTR, tooltip);
            }
            if (selectInputDate.isDisabled()) {
                dateText.setAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR);
            }
            if (selectInputDate.isReadonly()) {
                dateText.setAttribute(HTML.READONLY_ATTR, HTML.READONLY_ATTR);
            }
            int maxlength = selectInputDate.getMaxlength();
            if (maxlength > 0) {
                dateText.setAttribute(HTML.MAXLENGTH_ATTR, String.valueOf(maxlength));
            }
            root.appendChild(dateText);
            Element calendarButton = domContext.createElement(HTML.INPUT_ELEM);
            calendarButton.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_BUTTON);
            calendarButton.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_BUTTON);
            calendarButton.setAttribute(HTML.TYPE_ATTR, "image");
            calendarButton.setAttribute(HTML.ONFOCUS_ATTR, "setFocus('');");
            calendarButton.setAttribute(HTML.ONMOUSEDOWN_ATTR,
                    "if (Event.isLeftClick(event)) this.selfClick = true;");
            calendarButton.setAttribute(HTML.ONKEYDOWN_ATTR,
                    "if (event.keyCode == 13 || event.keyCode == 32) this.selfClick = true;");
            // render onclick to set value of hidden field to true
            String formClientId = parentForm.getClientId(facesContext);
            String hiddenValue1 = "document.forms['" + formClientId + "']['"
                    + this.getLinkId(facesContext, uiComponent) + "'].value='";
            String hiddenValue2 = "document.forms['" + formClientId + "']['"
                    + getHiddenFieldName(facesContext, uiComponent) + "'].value='";
            String onClick = "if (!this.selfClick) return false; this.selfClick = false; " + hiddenValue1
                    + clientId + CALENDAR_BUTTON + "';" + hiddenValue2 + "toggle';"
                    + "iceSubmitPartial( document.forms['" + formClientId + "'], this,event);" + hiddenValue1
                    + "';" + hiddenValue2 + "';" + "Ice.Calendar.addCloseListener('" + clientId + "','"
                    + formClientId + "','" + this.getLinkId(facesContext, uiComponent) + "','"
                    + getHiddenFieldName(facesContext, uiComponent) + "');" + "return false;";
            calendarButton.setAttribute(HTML.ONCLICK_ATTR, onClick);
            if (selectInputDate.getTabindex() != null) {
                try {
                    int tabIndex = Integer.valueOf(selectInputDate.getTabindex()).intValue();
                    tabIndex += 1;
                    calendarButton.setAttribute(HTML.TABINDEX_ATTR, String.valueOf(tabIndex));
                } catch (NumberFormatException e) {
                    if (log.isInfoEnabled()) {
                        log.info("NumberFormatException on tabindex");
                    }
                }
            }

            if (selectInputDate.isDisabled()) {
                calendarButton.setAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR);
            }
            if (selectInputDate.isReadonly()) {
                calendarButton.setAttribute(HTML.READONLY_ATTR, HTML.READONLY_ATTR);
            }
            root.appendChild(calendarButton);
            // render a hidden field to manage the popup state; visible || hidden
            FormRenderer.addHiddenField(facesContext, getHiddenFieldName(facesContext, uiComponent));
            String resolvedSrc;
            if (popupState) {
                JavascriptContext.addJavascriptCall(facesContext, "Ice.util.adjustMyPosition('" + clientId
                        + CALENDAR_TABLE + "', '" + clientId + ROOT_DIV + "');");
                if (selectInputDate.isImageDirSet()) {
                    resolvedSrc = CoreUtils.resolveResourceURL(facesContext,
                            selectInputDate.getImageDir() + selectInputDate.getClosePopupImage());
                } else {
                    // ICE-2127: allow override of button images via CSS
                    calendarButton.setAttribute(HTML.CLASS_ATTR, selectInputDate.getClosePopupClass());
                    // without this Firefox would display a default text on top of the image
                    resolvedSrc = CoreUtils.resolveResourceURL(facesContext,
                            selectInputDate.getImageDir() + "spacer.gif");
                }
                calendarButton.setAttribute(HTML.SRC_ATTR, resolvedSrc);
                addAttributeToElementFromResource(facesContext, CLOSE_POPUP_ALT, calendarButton, HTML.ALT_ATTR);
                addAttributeToElementFromResource(facesContext, CLOSE_POPUP_TITLE, calendarButton,
                        HTML.TITLE_ATTR);
            } else {
                if (selectInputDate.isImageDirSet()) {
                    resolvedSrc = CoreUtils.resolveResourceURL(facesContext,
                            selectInputDate.getImageDir() + selectInputDate.getOpenPopupImage());
                } else {
                    // ICE-2127: allow override of button images via CSS
                    calendarButton.setAttribute(HTML.CLASS_ATTR, selectInputDate.getOpenPopupClass());
                    // without this Firefox would display a default text on top of the image
                    resolvedSrc = CoreUtils.resolveResourceURL(facesContext,
                            selectInputDate.getImageDir() + "spacer.gif");
                }
                calendarButton.setAttribute(HTML.SRC_ATTR, resolvedSrc);
                addAttributeToElementFromResource(facesContext, OPEN_POPUP_ALT, calendarButton, HTML.ALT_ATTR);
                addAttributeToElementFromResource(facesContext, OPEN_POPUP_TITLE, calendarButton,
                        HTML.TITLE_ATTR);
                FormRenderer.addHiddenField(facesContext, formClientId
                        + UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance()) + "j_idcl");
                FormRenderer.addHiddenField(facesContext, clientId + CALENDAR_CLICK);
                PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent,
                        passThruAttributesWithoutTabindex);
                domContext.stepOver();
                return;
            }

            Text br = domContext.createTextNodeUnescaped("<br/>");
            root.appendChild(br);

            Element calendarDiv = domContext.createElement(HTML.DIV_ELEM);
            calendarDiv.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_POPUP);
            calendarDiv.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_POPUP);
            calendarDiv.setAttribute(HTML.STYLE_ELEM, "position:absolute;z-index:10;");
            addAttributeToElementFromResource(facesContext, POPUP_CALENDAR_TITLE, calendarDiv, HTML.TITLE_ATTR);
            table.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_TABLE);
            table.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_TABLE);
            table.setAttribute(HTML.CLASS_ATTR, selectInputDate.getStyleClass());
            table.setAttribute(HTML.STYLE_ATTR, "position:absolute;");
            table.setAttribute(HTML.CELLPADDING_ATTR, "0");
            table.setAttribute(HTML.CELLSPACING_ATTR, "0");
            // set mouse events on table bug 372
            String mouseOver = selectInputDate.getOnmouseover();
            table.setAttribute(HTML.ONMOUSEOVER_ATTR, mouseOver);
            String mouseOut = selectInputDate.getOnmouseout();
            table.setAttribute(HTML.ONMOUSEOUT_ATTR, mouseOut);
            String mouseMove = selectInputDate.getOnmousemove();
            table.setAttribute(HTML.ONMOUSEMOVE_ATTR, mouseMove);

            addAttributeToElementFromResource(facesContext, POPUP_CALENDAR_SUMMARY, table, HTML.SUMMARY_ATTR);
            Element positionDiv = domContext.createElement(HTML.DIV_ELEM);
            positionDiv.appendChild(table);
            calendarDiv.appendChild(positionDiv);
            Text iframe = domContext.createTextNodeUnescaped("<!--[if lte IE" + " 6.5]><iframe src='"
                    + CoreUtils.resolveResourceURL(FacesContext.getCurrentInstance(), "/xmlhttp/blank")
                    + "' class=\"iceSelInpDateIFrameFix\"></iframe><![endif]-->");
            calendarDiv.appendChild(iframe);
            root.appendChild(calendarDiv);

        } else {
            if (log.isTraceEnabled()) {
                log.trace("Select input Date Normal");
            }
            table.setAttribute(HTML.ID_ATTR, clientId + CALENDAR_TABLE);
            table.setAttribute(HTML.NAME_ATTR, clientId + CALENDAR_TABLE);
            table.setAttribute(HTML.CLASS_ATTR, selectInputDate.getStyleClass());
            addAttributeToElementFromResource(facesContext, CALENDAR_TITLE, table, HTML.TITLE_ATTR);
            table.setAttribute(HTML.CELLPADDING_ATTR, "0");
            table.setAttribute(HTML.CELLSPACING_ATTR, "0");
            // set mouse events on table bug 372
            String mouseOver = selectInputDate.getOnmouseover();
            table.setAttribute(HTML.ONMOUSEOVER_ATTR, mouseOver);
            String mouseOut = selectInputDate.getOnmouseout();
            table.setAttribute(HTML.ONMOUSEOUT_ATTR, mouseOut);
            String mouseMove = selectInputDate.getOnmousemove();
            table.setAttribute(HTML.ONMOUSEMOVE_ATTR, mouseMove);
            addAttributeToElementFromResource(facesContext, CALENDAR_SUMMARY, table, HTML.SUMMARY_ATTR);
            root.appendChild(table);

            Element dateText = domContext.createElement(HTML.INPUT_ELEM);
            dateText.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN);
            dateText.setAttribute(HTML.VALUE_ATTR, selectInputDate.getTextToRender());
            dateText.setAttribute(HTML.ID_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT);
            dateText.setAttribute(HTML.NAME_ATTR, clientId + SelectInputDate.CALENDAR_INPUTTEXT);
            root.appendChild(dateText);
        }
    }
    clientId = uiComponent.getClientId(facesContext);

    String[] weekdays = mapWeekdays(symbols);
    String[] weekdaysLong = mapWeekdaysLong(symbols);
    String[] months = mapMonths(symbols);

    // use the currentDay to set focus - do not set
    int lastDayInMonth = timeKeeper.getActualMaximum(Calendar.DAY_OF_MONTH);
    int currentDay = timeKeeper.get(Calendar.DAY_OF_MONTH); // starts at 1

    if (currentDay > lastDayInMonth) {
        currentDay = lastDayInMonth;
    }

    timeKeeper.set(Calendar.DAY_OF_MONTH, 1);

    int weekDayOfFirstDayOfMonth = mapCalendarDayToCommonDay(timeKeeper.get(Calendar.DAY_OF_WEEK));

    int weekStartsAtDayIndex = mapCalendarDayToCommonDay(timeKeeper.getFirstDayOfWeek());

    // do not require a writer - clean out all methods that reference a writer
    ResponseWriter writer = facesContext.getResponseWriter();

    Element root = (Element) domContext.getRootNode();

    Element table = null;
    if (selectInputDate.isRenderAsPopup()) {
        if (log.isTraceEnabled()) {
            log.trace("SelectInputDate as Popup");
        }

        // assumption input text is first child
        Element dateText = (Element) root.getFirstChild();
        //System.out.println("dateText  currentValue: " + currentValue);
        dateText.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT); // ICE-2302
        dateText.setAttribute(HTML.VALUE_ATTR, selectInputDate.getTextToRender());
        int maxlength = selectInputDate.getMaxlength();
        if (maxlength > 0) {
            dateText.setAttribute(HTML.MAXLENGTH_ATTR, String.valueOf(maxlength));
        }

        // get tables , our table is the first and only one
        NodeList tables = root.getElementsByTagName(HTML.TABLE_ELEM);
        // assumption we want the first table in tables. there should only be one
        table = (Element) tables.item(0);

        PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent,
                passThruAttributesWithoutTabindex);

        Element tr1 = domContext.createElement(HTML.TR_ELEM);

        table.appendChild(tr1);
        writeMonthYearHeader(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay, tr1,
                selectInputDate.getMonthYearRowClass(), currentLocale, months, weekdays, weekdaysLong,
                converter);

        Element tr2 = domContext.createElement(HTML.TR_ELEM);
        table.appendChild(tr2);

        writeWeekDayNameHeader(domContext, weekStartsAtDayIndex, weekdays, facesContext, writer,
                selectInputDate, tr2, selectInputDate.getWeekRowClass(), timeKeeper, months, weekdaysLong,
                converter);

        writeDays(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay,
                weekStartsAtDayIndex, weekDayOfFirstDayOfMonth, lastDayInMonth, table, months, weekdays,
                weekdaysLong, converter, (actuallyHaveTime ? value : null));
    } else {
        if (log.isTraceEnabled()) {
            log.trace("renderNormal::endcodeEnd");
        }
        // assume table is the first child
        table = (Element) root.getFirstChild();

        PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, passThruAttributes);

        Element tr1 = domContext.createElement(HTML.TR_ELEM);
        table.appendChild(tr1);

        writeMonthYearHeader(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay, tr1,
                selectInputDate.getMonthYearRowClass(), currentLocale, months, weekdays, weekdaysLong,
                converter);

        Element tr2 = domContext.createElement(HTML.TR_ELEM);

        writeWeekDayNameHeader(domContext, weekStartsAtDayIndex, weekdays, facesContext, writer,
                selectInputDate, tr2, selectInputDate.getWeekRowClass(), timeKeeper, months, weekdaysLong,
                converter);

        table.appendChild(tr2);

        writeDays(domContext, facesContext, writer, selectInputDate, timeKeeper, currentDay,
                weekStartsAtDayIndex, weekDayOfFirstDayOfMonth, lastDayInMonth, table, months, weekdays,
                weekdaysLong, converter, (actuallyHaveTime ? value : null));
    }

    //System.out.println("SIDR.encodeEnd()  isTime? " + SelectInputDate.isTime(converter));
    if (SelectInputDate.isTime(converter)) {
        Element tfoot = domContext.createElement(HTML.TFOOT_ELEM);
        Element tr = domContext.createElement(HTML.TR_ELEM);
        Element td = domContext.createElement(HTML.TD_ELEM);
        td.setAttribute(HTML.COLSPAN_ATTR, selectInputDate.isRenderWeekNumbers() ? "8" : "7");
        td.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeClass());
        Element tbl = domContext.createElement(HTML.TABLE_ELEM);
        Element tr2 = domContext.createElement(HTML.TR_ELEM);
        Element tdHours = domContext.createElement(HTML.TD_ELEM);
        Element hours = domContext.createElement(HTML.SELECT_ELEM);
        hours.setAttribute(HTML.ID_ATTR, clientId + SELECT_HOUR);
        hours.setAttribute(HTML.NAME_ATTR, clientId + SELECT_HOUR);
        hours.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass());
        hours.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL);

        // Convert from an hour to an index into the list of hours
        int hrs[] = selectInputDate.getHours(facesContext);
        //System.out.println("SIDR.encodeEnd()  hrs: " + hrs[0] + ", " + hrs[hrs.length-1]);
        int hourIndex;
        int min;
        int sec;
        int amPm;
        //System.out.println("SIDR.encodeEnd()  actuallyHaveTime: " + actuallyHaveTime);
        if (!actuallyHaveTime && selectInputDate.getHoursSubmittedValue() != null
                && selectInputDate.getMinutesSubmittedValue() != null) {
            //System.out.println("SIDR.encodeEnd()  Using submitted hours and minutes");
            hourIndex = selectInputDate.getHoursSubmittedValue().intValue();
            //System.out.println("SIDR.encodeEnd()  hour: " + hourIndex);
            min = selectInputDate.getMinutesSubmittedValue().intValue();
            //System.out.println("SIDR.encodeEnd()  min: " + min);
            String amPmStr = selectInputDate.getAmPmSubmittedValue();
            //System.out.println("SIDR.encodeEnd()  amPmStr: " + amPmStr);
            if (amPmStr != null) {
                amPm = amPmStr.equalsIgnoreCase("PM") ? 1 : 0;
            } else {
                amPm = (hourIndex >= 12) ? 1 : 0;
            }
            //System.out.println("SIDR.encodeEnd()  amPm: " + amPm);
            if (hrs[0] == 1) {
                hourIndex--;
                if (hourIndex < 0) {
                    hourIndex = hrs.length - 1;
                }
            }
            //System.out.println("SIDR.encodeEnd()  hourIndex: " + hourIndex);
        } else {
            if (hrs.length > 12) {
                hourIndex = timeKeeper.get(Calendar.HOUR_OF_DAY);
                //System.out.println("SIDR.encodeEnd()  hour 24: " + hourIndex);
            } else {
                hourIndex = timeKeeper.get(Calendar.HOUR);
                //System.out.println("SIDR.encodeEnd()  hour 12: " + hourIndex);
            }
            if (hrs[0] == 1) {
                hourIndex--;
                if (hourIndex < 0) {
                    hourIndex = hrs.length - 1;
                }
            }
            //System.out.println("SIDR.encodeEnd()  hourIndex: " + hourIndex);

            min = timeKeeper.get(Calendar.MINUTE);
            amPm = timeKeeper.get(Calendar.AM_PM);
            //System.out.println("SIDR.encodeEnd()  amPm: " + amPm);
        }
        if (!actuallyHaveTime && selectInputDate.getSecondsSubmittedValue() != null) {
            sec = selectInputDate.getSecondsSubmittedValue().intValue();
        } else {
            sec = timeKeeper.get(Calendar.SECOND);
        }
        for (int i = 0; i < hrs.length; i++) {
            Element hoursOption = domContext.createElement(HTML.OPTION_ELEM);
            hoursOption.setAttribute(HTML.VALUE_ATTR, String.valueOf(hrs[i]));
            Text hourText = domContext.createTextNode(String.valueOf(hrs[i]));
            hoursOption.appendChild(hourText);
            if (i == hourIndex) {
                hoursOption.setAttribute(HTML.SELECTED_ATTR, "true");
            }
            hours.appendChild(hoursOption);
        }
        Element tdColon = domContext.createElement(HTML.TD_ELEM);
        Element tdMinutes = domContext.createElement(HTML.TD_ELEM);
        Element minutes = domContext.createElement(HTML.SELECT_ELEM);
        minutes.setAttribute(HTML.ID_ATTR, clientId + SELECT_MIN);
        minutes.setAttribute(HTML.NAME_ATTR, clientId + SELECT_MIN);
        minutes.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass());
        minutes.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL);
        for (int i = 0; i < 60; i++) {
            Element minutesOption = domContext.createElement(HTML.OPTION_ELEM);
            minutesOption.setAttribute(HTML.VALUE_ATTR, String.valueOf(i));
            String digits = String.valueOf(i);
            if (i < 10) {
                digits = "0" + digits;
            }
            Text minuteText = domContext.createTextNode(digits);
            minutesOption.appendChild(minuteText);
            if (i == min) {
                minutesOption.setAttribute(HTML.SELECTED_ATTR, "true");
            }
            minutes.appendChild(minutesOption);
        }

        Text colon = domContext.createTextNode(":");
        tfoot.appendChild(tr);
        tr.appendChild(td);
        td.appendChild(tbl);
        tbl.appendChild(tr2);
        tdHours.appendChild(hours);
        tr2.appendChild(tdHours);
        tdColon.appendChild(colon);
        tdMinutes.appendChild(minutes);
        tr2.appendChild(tdColon);
        tr2.appendChild(tdMinutes);

        if (selectInputDate.isSecond(facesContext)) {
            Element tdSeconds = domContext.createElement(HTML.TD_ELEM);
            Element tdSecColon = domContext.createElement(HTML.TD_ELEM);
            Element seconds = domContext.createElement(HTML.SELECT_ELEM);
            seconds.setAttribute(HTML.ID_ATTR, clientId + SELECT_SEC);
            seconds.setAttribute(HTML.NAME_ATTR, clientId + SELECT_SEC);
            seconds.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass());
            seconds.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL);
            for (int i = 0; i < 60; i++) {
                Element secondsOption = domContext.createElement(HTML.OPTION_ELEM);
                secondsOption.setAttribute(HTML.VALUE_ATTR, String.valueOf(i));
                String digits = String.valueOf(i);
                if (i < 10) {
                    digits = "0" + digits;
                }
                Text secondText = domContext.createTextNode(digits);
                secondsOption.appendChild(secondText);
                if (i == sec) {
                    secondsOption.setAttribute(HTML.SELECTED_ATTR, "true");
                }
                seconds.appendChild(secondsOption);
            }
            Text secondColon = domContext.createTextNode(":");
            tdSecColon.appendChild(secondColon);
            tdSeconds.appendChild(seconds);
            tr2.appendChild(tdSecColon);
            tr2.appendChild(tdSeconds);
        }

        if (selectInputDate.isAmPm(facesContext)) {
            Element tdAamPm = domContext.createElement(HTML.TD_ELEM);
            Element amPmElement = domContext.createElement(HTML.SELECT_ELEM);
            amPmElement.setAttribute(HTML.ID_ATTR, clientId + SELECT_AM_PM);
            amPmElement.setAttribute(HTML.NAME_ATTR, clientId + SELECT_AM_PM);
            amPmElement.setAttribute(HTML.CLASS_ATTR, selectInputDate.getTimeDropDownClass());
            amPmElement.setAttribute(HTML.ONCHANGE_ATTR, DomBasicRenderer.ICESUBMITPARTIAL);
            String[] symbolsAmPm = symbols.getAmPmStrings();

            Element amPmElementOption = domContext.createElement(HTML.OPTION_ELEM);
            amPmElementOption.setAttribute(HTML.VALUE_ATTR, "AM");
            Text amPmElementText = domContext.createTextNode(symbolsAmPm[0]);
            amPmElementOption.appendChild(amPmElementText);

            Element amPmElementOption2 = domContext.createElement(HTML.OPTION_ELEM);
            amPmElementOption2.setAttribute(HTML.VALUE_ATTR, "PM");
            Text amPmElementText2 = domContext.createTextNode(symbolsAmPm[1]);
            amPmElementOption2.appendChild(amPmElementText2);
            if (amPm == 0) {
                amPmElementOption.setAttribute(HTML.SELECTED_ATTR, "true");
            } else {
                amPmElementOption2.setAttribute(HTML.SELECTED_ATTR, "true");
            }
            amPmElement.appendChild(amPmElementOption);
            amPmElement.appendChild(amPmElementOption2);
            tdAamPm.appendChild(amPmElement);
            tr2.appendChild(tdAamPm);
        }
        table.appendChild(tfoot);
    }
    // purge child components as they have been encoded no need to keep them around
    selectInputDate.getChildren().clear();

    // steps to the position where the next sibling should be rendered
    domContext.stepOver();
}