I'm making an application for work calculations. I need to receive two dates and know the amount of days / months / years. Ex: 08/03/2017 to 07/03/2018 is for 12 months accurate, in my code of 11 months and 27 days someone knows how to fix it.
String dataEntrada, dataSaida;
dataEntrada = JOptionPane.showInputDialog(null, "Digite a data de entrada");
dataSaida = JOptionPane.showInputDialog(null, "Digite a data de saida");
String entrada[] = dataEntrada.split("/");
String saida[] = dataSaida.split("/");
LocalDate admissao = LocalDate.of(Integer.parseInt(entrada[2]), Integer.parseInt(entrada[1]),
Integer.parseInt(entrada[0]));
LocalDate demissao = LocalDate.of(Integer.parseInt(saida[2]), Integer.parseInt(saida[1]),
Integer.parseInt(saida[0]));
Period periodo = Period.between(admissao, demissao);
System.out
.println(periodo.getYears() + " Anos " + periodo.getMonths() + " Meses " + periodo.getDays() + " Dias");