Formatear Fechas

Formulario

<p:commandButton action="#{programacionVechicularController.imprimir()}" value="Reporte"
                        icon="icon-report" ajax="false">
</p:commandButton>

En el controller

  public String showDate(Date date) {
        String h = "";
        try {
            h = DateUtil.dateFormatToString(date, "dd/MM/yyyy");
        } catch (Exception e) {
            JsfUtil.errorMessage("showDate() " + e.getLocalizedMessage());
        }
        return h;
    }
    
     public String showHour(Date date) {
        String h = "";
        try {
            h = DateUtil.hourFromDateToString(date);
        } catch (Exception e) {
            JsfUtil.errorMessage("showHour() " + e.getLocalizedMessage());
        }
        return h;
    }

Invocarlo

Método

Last updated

Was this helpful?