because this error is in java, Can not format given Object as a Date?

0

I have the following method

   public List<String> llenaDiasAnioMes() {

    Date date = null;
    List<String> lDias = new ArrayList<>();
    for (Integer i = 1; i <= this.getLongitudMes(); i++) {

        String fechaActual = i.toString() + "-" +mes.toString() + "-"+annio.toString();
        lDias.add(fechaActual);

        DateFormat inputFormat = new SimpleDateFormat("dd-MM-yyyy");
        String fechaString = String.join(", ", lDias);

        System.out.println("PRUBAA LISTA\n" +fechaString);




        try {
            date = inputFormat.parse(fechaString);
            System.out.println("PRUEBA DATE\n" +date);
        } catch (ParseException ex) {
            Logger.getLogger(RegistroAccesoComponentImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    return lDias;

}

to the list I pass the days, the month and the year where the month and the year, I get them like this:

 mes = LocalDate.now().getMonth().getValue();
        

        Year año = Year.now();
        annio = año.getValue();

I have the following table

<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()}">
      <f:convertDateTime type="date" pattern="dd-MM-yyyy" />
    </h:outputText>
  </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>

in the date column, I want to show the corresponding days of the month, in this format dd / mm / yyyy as here

and in console I get the following

PRUBAA LISTA
1-3-2018
PRUEBA DATE
Thu Mar 01 00:00:00 CST 2018
PRUBAA LISTA
1-3-2018, 2-3-2018
PRUEBA DATE
Thu Mar 01 00:00:00 CST 2018
PRUBAA LISTA
1-3-2018, 2-3-2018, 3-3-2018
PRUEBA DATE
Thu Mar 01 00:00:00 CST 2018
PRUBAA LISTA
1-3-2018, 2-3-2018, 3-3-2018, 4-3-2018
PRUEBA DATE
Thu Mar 01 00:00:00 CST 2018

and this error comes out

Could not convert '[1-3-2018, 2-3-2018, 3-3-2018,n] to a string.
Caused By: java.lang.IllegalArgumentException: Cannot format given Object as a Date

and what you notice is in the print of System.out.println ("PROOF DATE \ n" + date); comes out the same thing

How can I solve this, so that it shows me the date in the correct format?

    
asked by Root93 06.03.2018 в 00:55
source

0 answers