上面的方法返回一个零区间,虽然周期的计算是正确的,告诉我错误是什么。
private Period kavendarVisl(DefaultTableModel dtm)
{
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
Period period = Period.ZERO;
Period smalPeriod;
for (int row=0;row<dtm.getRowCount();row++)
{
LocalDate ld1=LocalDate.parse(dtm.getValueAt(row,0).toString(),formatter);
LocalDate ld2 = LocalDate.now();
if (!dtm.getValueAt(row,1).toString().equals(""))
{
ld2=LocalDate.parse(dtm.getValueAt(row,1).toString(),formatter);
}
smalPeriod = Period.between(ld1,ld2);
period.plus(smalPeriod);
System.out.println(smalPeriod.getYears() + " - " + smalPeriod.getMonths());
}
System.out.println(period.getYears() +" - " +period.getMonths());
return period;
}
期间 = 期间.plus(smalPeriod);