How to display the dd / mm / yyyy format in java within a table?

0

I have the following code that brings me the current month and year

// Obtienes el mes actual 
mes = LocalDate.now().getMonth().getValue(); 

//Se obtiene el año actual 
Year año = Year.now();
annio = año.getValue(); 

I have this method

 public List<Integer> llenaDiasAnioMes() {

    List<Integer> lDias = new ArrayList<>();
    for (int i = 1; i <= this.getLongitudMes(); i++) {
        lDias.add(i);
        lDias.add(mes);
        lDias.add(annio);
    }
    return lDias;

}

and throws me in console the following

LISTA DIAS[1, 2, 2018, 2, 2, 2018, 3, 2, 2018, 4, 2, 2018, 5, 2, 2018, 6, 2, 2018, 7, 2, 2018, 8, 2, 2018, 9, 2, 2018, 10, 2, 2018, 11, 2, 2018, 12, 2, 2018, 13, 2, 2018, 14, 2, 2018, 15, 2, 2018, 16, 2, 2018, 17, 2, 2018, 18, 2, 2018, 19, 2, 2018, 20,
2, 2018, 21, 2, 2018, 22, 2, 2018, 23, 2, 2018, 24, 2, 2018, 25, 2, 2018, 26, 2, 2018, 27, 2, 2018, 28, 2, 2018]

It shows me all the days of the month of February (28), with the current month and year

Now, what I want to do is pass that data to a table that they look like this, that in the column of date they appear all the days of the month with the current year, of this form 23/02/2018, and so if it changes of month, that it changes the days corresponding to that month

I have my table this way

<p:dataTable id="detalle" var="detalle" styleClass="columns" value="#{RegistroAccesoComponent.incidenciaAnioMesDet}" emptyMessage="No se encontraron registros.">

  <p:columnGroup type="header">
    <p:row>

      <p:column headerText="FECHA" style="width:20px;" styleClass="columns" />
      <p:column headerText="ENTRADA" style="width:20px;" styleClass="columns" />
      <p:column headerText="SALIDA" style="width:20px;" styleClass="columns" />
      <p:column headerText="INCIDENCIA" style="width:60px;" styleClass="columns" />
      <p:column headerText="ACCION" style="width:10px;" styleClass="columns" />
    </p:row>
  </p:columnGroup>
  <p:column styleClass="columns">
    <h:outputText value="#{RegistroAccesoComponent.llenaDiasAnioMes()}" />
  </p:column>

  <p:column styleClass="columns">
    <h:outputText value="#{detalle.horaEntrada}">
      <f:convertDateTime type="date" timeZone="CST" pattern="HH:mm:ss" />
    </h:outputText>

  </p:column>
  <p:column styleClass="columns">
    <h:outputText value="#{detalle.horaSalida}">
      <f:convertDateTime type="date" timeZone="CST" pattern="HH:mm:ss" />
    </h:outputText>
  </p:column>
  <p:column styleClass="columns">
    <h:outputText value="#{detalle.incidencias.cveIdIncidencia}  #{detalle.incidencias.concepto}" />
  </p:column>
  <p:column styleClass="columns">
    <p:commandButton icon="ui-icon-search" title="View" onclick="PF('modalIntentos').show();">
    </p:commandButton>
  </p:column>
</p:dataTable>

and in the first column I send to call the method that returns me the days with the month and the year, but it shows me in this way

How can I paint it by row on the days of the month, as well as on the image? or what other form can I get every day of the month and show them in that format?

    
asked by Root93 23.02.2018 в 23:13
source

1 answer

0

To format a column use the converter property like the one you use in the column that you can use as an example, it shows well pattern="dd/MM/yyyy"

<p:column styleClass="columns">
<h:outputText value="#{detalle.horaEntrada}">
  <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
</h:outputText>

You will have to first format the date, then setter with the new date to the list where the samples.

DateFormat inputFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

String fechaString= "05-03-2018 12:00";
Date date = inputFormat.parse(fechaString);
    
answered by 26.02.2018 в 18:58