I need to sort an array based on the Date field of it, so I made this code.
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
for(int i = 0; i < arrayCapacitacaoAux.size(); i++){
String dadosA = (String)arrayCapacitacaoAux.get(i);
String infoA[] = dadosA.split("\|");
Date dataA = (Date)format.parse(infoA[9]);
for(int j = 0; j < arrayCapacitacaoAux.size()-i; j++){
String dadosB = (String)arrayCapacitacaoAux.get(j);
String infoB[] = dadosB.split("\|");
Date dataB = (Date)format.parse(infoB[9]);
if (dataA.after(dataB)) {
}
}
}
There are some things I need to say before.
arrayCapacitacaoAux.add(pageContext.getAttribute("data").toString()+"|"+nomeCurso +"|"+local+"|"+imagemApresentacao+"|"+horario +"|"+cargaHoraria +"|"+publicoAlvo+"|"+paginaEdit+"|"+periodo+"|"+dataFinal);
And so I get the data the way it is in the code I posted.
Finally, I arrived in this part and a half that I lost, the only time I did the Buble sort was in C, but it does not change so much, the problem is that I am now using arraylist, can you give me a help in this? Thank you guys!